[Webkit-unassigned] [Bug 104096] New: form.elements.namedItem() return undefined instead of null

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 5 00:47:41 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=104096

           Summary: form.elements.namedItem() return undefined instead of
                    null
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Unspecified
        OS/Version: Unspecified
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: HTML DOM
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: a.semenov at unipro.ru


HTML5 specification ( http://www.w3.org/TR/html5/the-form-element.html#the-form-element )
define for element 'form' property 'elements' of type HTMLFormControlsCollection.
The HTMLFormControlsCollection is defined as follows ( http://www.w3.org/TR/html5/common-dom-interfaces.html#htmlformcontrolscollection-0 ):

interface HTMLFormControlsCollection : HTMLCollection {
  // inherits length and item()
  legacycaller getter object? namedItem(DOMString name); // overrides inherited namedItem()
};

"The namedItem(name) method must act according to the following algorithm:

1. If, at the time the method is called, there is exactly one node in the collection that has either an id attribute or a name attribute equal to name, then return that node and stop the algorithm.
2. Otherwise, if there are no nodes in the collection that have either an id attribute or a name attribute equal to name, then return null and stop the algorithm.
3. Otherwise, create a new RadioNodeList object representing a live view of the HTMLFormControlsCollection object, further filtered so that the only nodes in the RadioNodeList object are those that have either an id attribute or a name attribute equal to name. The nodes in the RadioNodeList object must be sorted in tree order.
4. Return that RadioNodeList object."

However, namedItem() returns undefined result instead of null for the case #2.

Here is sample code:

<html>
<head>
<script type="text/javascript">

function test() {
        var form = document.createElement('form');
        document.body.appendChild(form);

        document.write('form.elements.namedItem("non-existing-id"): ' + form.elements.namedItem('non-existing-id') + ' (expected: null)');
}
</script>
</head>
<body onload="test()">
</body>
</html>

The problem is found in Google Chrome 23.0.1271.91 (Official build 167501) m

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list