-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formalize content attribute reflection #3238
Comments
I think we should definitely move this stuff into IDL if possible. However, when I've tried in the past, I've gotten stuck. Basically, my intuition was that it would be too confusing to only move some of the stuff into IDL, and leave the rest in prose. Which means solving it all at once. Which is hard. Some particular issues:
It's possible others would find it OK to only have some of the reflection defined in IDL and others defined in prose, at least for now. I'd welcome thoughts. But my instinct is to try to put in a lot of work to come up with the perfect scheme that covers all cases, including modifying Web IDL to give us better syntax, and do it all at once. Which is hard :). |
If we have a rough plan for all of it, I wouldn't mind it landing in phases. Some thoughts on the particulars:
|
Quoting from WebIDL:
So it's easy to add other forms, see for example the proposed wildcard attributed for So adding support for
|
It should also be noted that at least Servo's, Gecko's and Blink's WebIDL parsers already understand this syntax. |
Note that at least for |
Edge also uses custom extended attributes for reflection. We've just added this for Edge15 (next version of Edge, so the syntax could change):
|
|
Seems like the only way to do that with current WebIDL is to do |
@nox, that's actually easy to fix, see: #3238 (comment). |
@domenic @tobie I just remembered that https://heycam.github.io/webidl/#prod-identifier That's why we can do this for CSSStyleDeclaration in Servo: [CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString backgroundPositionY;
[CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString background-position-y; |
OTOH, |
CC @arronei |
Re |
Some progress has been made on a concrete proposal for this over in the jsdom project. Our proposal so far is:
Examples (trimmed of various things that are not reflected attributes): interface HTMLInputElement : HTMLElement {
[CEReactions, Reflect="checked"] attribute boolean defaultChecked;
[CEReactions, ReflectNonNegative] attribute long maxLength;
};
interface HTMLBaseElement : HTMLElement {
[CEReactions, ReflectURL] attribute USVString href;
};
interface HTMLOListElement : HTMLElement {
[CEReactions, Reflect] attribute boolean reversed;
[CEReactions, Reflect, ReflectFallback=1] attribute long start;
};
interface HTMLTableColElement : HTMLElement {
[CEReactions, Reflect, ReflectRange=(1, 1000), ReflectFallback=1] attribute unsigned long span;
};
interface HTMLProgressElement : HTMLElement {
[CEReactions, ReflectPositive, ReflectFallback=1.0] attribute double max;
}; |
Other changes: * Remove reflection of unrestricted double as it is buggy and unused. * The DOMString getter steps did not account for a missing attribute. * The native accessibility semantics map was renamed to the internal content attribute map as it's now a more general reflection concept. Corresponding ARIA PR: w3c/aria#1876. Fixes #8442. Follow-up: * w3c/core-aam#152 * w3c/aria#1110 * #3238 * #8544 * #8545 * #8926 * #8927 * #8928 * #8930
The details surrounding content attribute reflection on specific attributes is currently only defined in prose, with the specification containing 199 variations of the sentence "The IDL attribute Foo must reflect the Bar content attribute" at the moment.
There are at least two implementations (Blink and jsdom) which have introduced Web IDL extended attributes declaring the specifics of the reflection in IDL. Here is an example:
[CEReactions, Reflect=checked] attribute boolean defaultChecked;
This uses the
[Reflect]
extended attribute to declare that thedefaultChecked
attribute should be reflected as thechecked
content attribute. The information can then be used to generated code that automatically handles the specifics of the reflection.In addition, Blink uses several variations of
[Reflect]
to cover cases including missing, invalid and limited sets of values. These extended attributes along with descriptions can be found on this page, but here is the summary:[Reflect]
indicates that a given attribute should reflect the values of a corresponding content attribute.[ReflectEmpty="value"]
gives the attribute keyword value to reflect when an attribute is present, but without a value; it supplements [ReflectOnly] and [Reflect].[ReflectInvalid="value"]
gives the attribute keyword value to reflect when an attribute has an invalid/unknown value. It supplements [ReflectOnly] and [Reflect].[ReflectMissing="value"]
gives the attribute keyword value to reflect when an attribute isn't present. It supplements [ReflectOnly] and [Reflect].[ReflectOnly=<list>]
indicates that a reflected string attribute should be limited to a set of allowable values; it supplements [Reflect].There are additional cases that could be considered such as when an attribute is defined as representing a URL. This is also only covered by prose at the moment.
I believe it would be helpful for implementations and aid in automated testing if the specification were to formally define and use extended attributes or another non-prose method to cover the details of reflection in Web IDL.
The text was updated successfully, but these errors were encountered: