It looks like IE and Firefox create a Nodelist to store multiple form inputs that share the same name. They allow for properties of this data structure to be set and retrieved. Safari (and Konqueror) seem to use something different (probably a DOMNamedNodesCollection?) that cannot be assigned new properties (adding properties fails silently). This problem was encountered when using CGI::FormBuilder to build forms with multiple submit buttons. CGI::FormBuilder's strategy is for these buttons to share the same name (_submit) and their onclick event handler to set _submit.value to the value of the button clicked. This value is retrievable in IE and Firefox, but not Safari and Konqueror. You can see the behaviour by going to: http://www.formbuilder.org/ex/multiple_submits.pl The validation code runs through even if you hit the cancel or delete buttons.
Created attachment 7289 [details] Simplified test case
It does look like the class used for items with the same name is a DOMNamedNodesCollection, defined in kjs_dom.h. From Darin: "Looking at DOMNamedNodesCollection::getOwnPropertySlot, it looks like it supports length, indexing by number, and indexing by ID." Should it also support setting and getting other properties as a Nodelist in Firefox/IE?
Comments on IRC suggest this also affects NodeList.
<rdar://problem/5725722>
I think the issue here is that we create a new collection object every time when a script requests the collection. Setting and getting properties works, but if you re-get the collection you are actually getting a different object.
*** Bug 9278 has been marked as a duplicate of this bug. ***
Bug 9278 has a test reduced from a Quirksmode report for accessing form element collections in a slightly different way via HTMLFormElement.elements.
I am unable to reproduce this bug with "Firefox" behavior described in Safari 15.6 on macOS 12.5 because now all browsers return "empty" dialog box upon clicking buttons on the attached test cases. Since all browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6 on macOS 12.5) are aligned and just show "" / undefined / empty dialog boxes on clicking the buttons rather than as mentioned of showing "One" or "Two" of value, I think this can be marked as "RESOLVED INVALID" because Firefox changed the behavior here where previously it used to show value of button clicked. Please reopen if I am incorrect. Thanks!