[whatwg] Questions and remarks about the labels attribute

Mounir Lamouri mounir.lamouri at gmail.com
Thu Mar 31 06:28:37 PDT 2011


Hi,

I'm working on the labels attribute implementation in Gecko and I have a
few remarks:

* I wonder what are the use cases for authors. I see some use cases for
browser vendors (a11y and UI for example) but what an author would do
with that attribute?

* The labels attribute returns a NodeList but all elements in the list
are HTMLLabelElement so an HTMLCollection sounds more appropriate,
doesn't it? Though, I might miss a difference between these two collections.
FWIW, Opera (only implementation AFAIK) returns an HTMLCollection.

* The most important issue is related to the collection returned by the
labels attribute. Given that the collection isn't stated to be static,
it is live (according to DOM Core). Though, the root element of the
collection might change: when an element is inside a document, it's
always the document but when it is outside, it is the root of the fragment.
One solution would be to explicitly say that labels can't labelize an
element outside of a document even if it is the first labelled control
descendant in the tree order. But how do we manage situations where
.labels is returned when an element isn't in a document then the element
is moved to a document? Should the root element of the collection change?
Another solution would be to make the collection static. Thus, we return
whatever seems appropriate depending on the element being in a document
or not. This solution seems also saner because it prevents watching the
entire document when .labels is used which is a bit of overkill.
Actually, I think that only form.elements returns a collection that
implies watching the entire document (because of the form attribute) all
other collections uses a sub-tree.

Thanks,
--
Mounir


More information about the whatwg mailing list