You need to be logged in to post in the forums. If you do not have an account, please sign up first.
I cannot use custom function on NodeList returned by document.querySelectorAll
Both document.getElementsByTagName and document.querySelectorAll return NodeList object.I extend NodeList.prototype with "myFunction":
NodeList.prototype.myFunction = function() { console.log("Hello, I am myFunction"); }
When I call:
document.getElementsByTagName("body").myFunction();
everything is right and "Hello..." is printed in console.
But when I call:
document.querySelectorAll("body").myFunction();
I get following error:
Unhandled Error: 'document.querySelectorAll("body").myFunction' is not a function
I this bug? Or am I doing something wrong?
Tested in console
on Opera 11.62 Build: 1347 and Opera 12.00 beta, Build 1387
Platform: Win32, System: Windows 7
I can confirm that. I don't know what the intended behavior is, but I would expect that it's a bug.
Opera 12.15 - Win 8 Pro x64 All my Opera tools -Tab Vault: Save tabs for later -AutoStack: tabs opened from a stack stay there