W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2005

namedItem method return value

From: Seo Sanghyeon <tinuviel@sparcs.kaist.ac.kr>
Date: Mon, 27 Jun 2005 20:14:03 +0900
To: www-dom@w3.org
Message-ID: <20050627111403.GA14022@sparcs.kaist.ac.kr>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:58 GMT