Skip to content

Formalize content attribute reflection #3238

@Zirro

Description

@Zirro

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 the defaultChecked attribute should be reflected as the checked 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clarificationStandard could be clearertopic: reflectFor issues with reflected IDL attributes and friends

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions