This is about attribute reflection for element references for things like ariaLabelledByElements
.
Imagine we have a label an an input:
<label id="foo">A label</label>
<input id="myinput" />
And we want to set a relationship between both in JavaScript:
myinput.ariaLabelledByElements = [ foo ];
Right now with the current spec text, the attribute aria-labelledby
will be set to foo
in the input
element. That's known as sprouting:
<label id="foo">A label</label>
<input id="myinput" aria-labelledby="foo"/>
This has a problem if something changes later, as we can leave out of sync IDs values there in different situations. Examples:
- The
label
ID gets modified:The HTML would be:foo.id = "bar";
But if you check the relationship from JavaScript or in the a11y tree, you still get the proper<label id="bar">A label</label> <input id="myinput" aria-labelledby="foo"/>
label
associated to the element. This would be very confusing if there's another element calledfoo
on the tree, as the attribute would be somehow pointing to that other element, while the actual relationship set is pointing to thebar
one. - The
label
element is removed from the tree:In this case attribute would have a stale ID:document.removeChild(foo);
<input id="myinput" aria-labelledby="foo"/>
Set always the empty string, that means that a element reference has been set from JavaScript. And we never get into the case of having an out of sync ID. If needed people could query which elements have an empty attribute to know if they have an underlying relationship set.
In the previous example when we do the association we'll get:
<label id="foo">A label</label>
<input id="myinput" aria-labelledby=""/>
So whatever changes later regarding the label
element has no bad effects.
- Issues: whatwg/html#8306 & whatwg/html#8307
- PR: whatwg/html#8352
- Tests: web-platform-tests/wpt#36253