The current HtmlFormElement.elements isn't quite right, and Form
is missing .item(), .namedItem(). The fun one is direct named
elements, ala...
<form name="foo">
<input name="bar" />
</form>
so...
var aform = document.foo; // this is works already
aform.bar // is the number element, OR...
document.foo.bar // is the input element
This is going to be a bugger, with lots of unit tests. But it's
one of the last biggies for core functionality in env.js.
--nickg
The spec http://dev.w3.org/html5/spec/Overview.html#dom-form-nameditem
sayz:
Form . elements
Returns an HTMLCollection of the form controls in the form (excluding image buttons for historical reasons).
form . length
Returns the number of form controls in the form (excluding image buttons for historical reasons).
element = form . item(index)
form[index]
form(index)
Returns the indexth element in the form (excluding image buttons for historical reasons).
element = form . namedItem(name)
form[name]
form(name)
Returns the form control in the form with the given ID or name (excluding image buttons for historical reasons).
Once an element has been referenced using a particular name, that name will continue being available as a way to reference that element in this method, even if the element's actual ID or name changes, for as long as the element remains in the Document.
If there are multiple matching items, then a NodeList object containing all those elements is returned.
Returns null if no element with that ID or name could be found.