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>


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:

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

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:12 UTC