Description
What is the issue with the HTML Standard?
ARIAMixin on Element says:
The ARIAMixin getter steps given element, idlAttribute, and contentAttribute are to return the result of the getter algorithm for idlAttribute reflecting contentAttribute on element.
The ARIAMixin setter steps given element, idlAttribute, contentAttribute, and value are to perform the setter algorithm for idlAttribute reflecting contentAttribute on element, given value.
So, let's go look at what the getter algorithm for, say, ariaLive
reflecting aria-live=""
would be. ariaLive
is defined as
[CEReactions] attribute DOMString? ariaLive;
i.e. it's a DOMString?
. But HTML's DOMString?
getter reflection says:
Assert: attributeDefinition indicates it is an enumerated attribute.
Assert: the reflected IDL attribute is limited to only known values.
Assert: contentAttributeValue corresponds to a state of attributeDefinition.
These asserts generally fail.
The spec might imply that the first succeeds: the definition for aria-live=""
states that its "Value:" is "token", and the ARIA type mapping states that "token" "Value:" should somehow map to HTML's Keywords and enumerated attributes section. (With what invalid value default and missing value default? What keyword vs. state mapping, exactly?)
For the second assert (and thus the third as well), there's no evidence that the attributes are limited to only known values. Testing in browsers, it's certainly not the case: document.body.ariaLive = "foo"
will happily work, with document.body.ariaLive === "foo"
on the next line succeeding.
And of course, picking ariaLive
was already stacking the deck in our favor. If we did ariaDescription
, which corresponds to the "string"-"Value:"d `aria-description="" attribute, then certainly it would not be an enumerated attribute.
Note that this seems to be implemented in all browsers, according to WPTs.
I see a few paths forward here:
-
1A. Allow
DOMString?
reflection for all attributes. Try to avoid using it in the future for such unrestricted cases. -
1B Allow
DOMString?
reflection for attributes starting witharia-*
only, as a legacy exception. -
2A Decide that
DOMString?
is a nicer way of doing string reflection thanDOMString
(since it distinguishes between the attribute being missing and it being present as the empty string), and going forward use it for all new HTML attributes that reflect as strings. -
2B Decide that
DOMString?
is a nicer way of doing string reflection thanDOMString
, and try to not only use it going forward, but to also change the behavior of existing HTML attributes. -
3 Try to change away from
DOMString?
to instead justDOMString
. The behavior change here is that absent attributes would return the empty string, and setting the value tonull
would no longer remove the attribute but would instead set the attribute's value to the string"null"
. -
4 On a case-by-case basis, update the ARIA IDL attributes to have the best possible reflection semantics, including possibly "limited to only known values" enumerated attribute behavior.
There are some previous issues tracking this on the ARIA side, most notably w3c/aria#1110, but I wanted to summarize the current state of things. Especially since the easiest path, like 1A or 1B, would involve changes solely to HTML.