Matt Kruse wrote:
Quote:
Richard Cornford wrote:
Quote:
>The - getElementsByTagName - method is specified as returning a
>NodeList, but may in reality return a NamedNodeMap.
>
I don't know much in this area, but I thought NodeList was the
interface, and that HTMLCollection was the implementation.
HTMLCollection is an interface, just line NodeList.
Quote:
I tried to extend NodeList also, but I got the same results.
Also, since (x instanceof HTMLCollection) == true, I thought
I was on the right track. If it doesn't return an HTMLCollection
object, why would that check be true?
The - instanceof - operator is not necessarily usefully discriminating
in javascript.
Quote:
Quote:
>If you want to draw conclusions about objects implementing
>HTMLCollection shouldn't you use a source that is specified
>as being one, such as - document.forms -?
>
I just tried that
Good, as starting with something that is supposed to be an -
HTMLCollection - eliminates possible sources of interference.
Quote:
as well with the same results.
Remember that - NodeList - and - NamedNodeMap - are specified (in the
ECMAScript bindings) as mapping bracket notation (and therefore, due to
ECMA 262 provisions, dot notation) property accessors onto their - item -
methods, and - HTMLCollection - is specified as mapping them onto its -
item - and - namedItem - methods. So your - x.funk - may be equivalent
to - x.namedItem('func') -, and as - namedItem - may only return an
object implementing the - Node - interface or null it should not be too
surprising if you don't get access to your method.
Quote:
Nevertheless, do you know which object, if any (except Object),
I could extend to add a method to the results returned by
getElementById()?
Objects implementing the - Element - interface are returned by-
getElementById -.
Richard.