W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2011

[whatwg] Questions and remarks about the labels attribute

From: Mounir Lamouri <mounir.lamouri@gmail.com>
Date: Thu, 31 Mar 2011 15:28:37 +0200
Message-ID: <4D948185.7030105@gmail.com>
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
Received on Thursday, 31 March 2011 06:28:37 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:31 UTC