namedItem method return value

Hello,

I think this must have been asked before, but I have a question:

DOM Level 2 HTML Specification says that namedItem method of HTMLCollection
returns Node. "It first searches for a Node with a matching id attribute.
If it doesn't find one, it then searches for a Node with a matching name
attribute, but only on those elements that are allowed a name attribute."

Now, it is possible that there are multiple Nodes with a matching name
attribute. What does the method return in that case? Actually, if a page
has radio buttons, it *will* have Nodes with the same name.

Internet Explorer and Mozilla both returns NodeList, but this must be
wrong since the specification states it should return Node.

Here's a demo:
http://sparcs.kaist.ac.kr/~tinuviel/tmp/nameditem.html

If document.forms['test'].elements['foo'] returns Node, it should have
nodeType attribute, but browsers say "undefined".

Seo Sanghyeon

Received on Monday, 27 June 2005 11:54:02 UTC