Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Introduce enumerated attribute reflection extended attributes#11455

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
lukewarlow wants to merge9 commits intowhatwg:main
base:main
Choose a base branch
Loading
fromlukewarlow:reflect-enum-idl

Conversation

lukewarlow
Copy link
Member

@lukewarlowlukewarlow commentedJul 15, 2025
edited by pr-previewbot
Loading

Introduce enumerated attribute reflection IDL

  • [ReflectEnum=identifier] can be used alongside [Reflect] on DOMString and DOMString? attributes to identify the IDL enum which holds the known value keywords.

Additionally, 3 new extended attributes are allowed on enums:

  • [InvalidValueDefault] and [InvalidValueDefault=string] sets the value to be used when the content attribute has an invalid value.

  • [MissingValueDefault] and [MissingValueDefault=string] sets the value to be used when the content attribute is missing.

  • [EmptyValueDefault] and [EmptyValueDefault=string] sets the value to be used when the content attribute is the empty string.

  • At least two implementers are interested (and none opposed):

  • Tests are written and can be reviewed and commented upon at:

  • Implementation bugs are filed:

    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno (only for timers, structured clone, base64 utils, channel messaging, module resolution, web workers, and web storage): …
    • Node.js (only for timers, structured clone, base64 utils, channel messaging, and module resolution): …
  • CorrespondingHTML AAM &ARIA in HTML issues & PRs:

  • MDN issue is filed: …

  • The top of this comment includes aclear commit message to use.

(SeeWHATWG Working Mode: Changes for more details.)


/common-dom-interfaces.html (diff )
/dom.html (diff )
/edits.html (diff )
/embedded-content-other.html (diff )
/embedded-content.html (diff )
/form-control-infrastructure.html (diff )
/form-elements.html (diff )
/forms.html (diff )
/grouping-content.html (diff )
/iframe-embed-object.html (diff )
/image-maps.html (diff )
/images.html (diff )
/index.html (diff )
/infrastructure.html (diff )
/input.html (diff )
/interaction.html (diff )
/interactive-elements.html (diff )
/links.html (diff )
/media.html (diff )
/obsolete.html (diff )
/popover.html (diff )
/scripting.html (diff )
/semantics.html (diff )
/tables.html (diff )
/text-level-semantics.html (diff )
/urls-and-fetching.html (diff )

A number of extended attributes are added which trigger IDL attribute reflection:- [Reflect] and [Reflect=string] cover basic content attribute reflection cases.- [ReflectURL] and [ReflectURL=string] covers reflection of USV attributes, which represent URLs.- [ReflectNonNegative] and [ReflectNonNegative=string] covers reflection of long attributes that should be limited to only non-negative numbers.- [ReflectPositive] and [ReflectPositive=string] covers reflection of double and unsigned long attributes which should be limited to positive numbers.- [ReflectPositiveWithFallback] and [ReflectPositiveWithFallback=string] covers reflection of double and unsigned long attributes which should be limited to positive numbers with fallback.Additionally:- [ReflectRange=(integer, integer)] can be used alongside others on unsigned long attributes that should be clamped to a range.- [ReflectDefault=number] can be used alongside others on double, long and unsigned long attributes that should be reflected with a default value.
@lukewarlow
Copy link
MemberAuthor

The second commit here is the interesting part for this specific PR, if you have feedback on the underlying stuff comment on#11450

@lukewarlow
Copy link
MemberAuthor

lukewarlow commentedJul 16, 2025
edited
Loading

Interestingly some of these attributes have their keywords defined in external specs. one of them (refererpolicy) has an enum definition, so potentially we could update that spec to simply add the [InvalidValueDefault, MissingValueDefaut] attributes to the enum. And refer to it from within the [ReflectEnum].

[SameObject, PutForwards=<span data-x="dom-DOMTokenList-value">value</span>, <span data-x="xattr-Reflect">Reflect</span>] readonly attribute <span>DOMTokenList</span> <dfn attribute for="HTMLLinkElement" data-x="dom-link-sizes">sizes</dfn>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>="<code data-x="attr-link-imagesrcset">imagesrcset</code>"] attribute USVString <dfn attribute for="HTMLLinkElement" data-x="dom-link-imageSrcset">imageSrcset</dfn>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>="<code data-x="attr-link-imagesizes">imagesizes</code>"] attribute DOMString <dfn attribute for="HTMLLinkElement" data-x="dom-link-imageSizes">imageSizes</dfn>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>="<span data-x="attr-link-referrerpolicy">referrerpolicy</span>", <span data-x="xattr-ReflectEnum">ReflectEnum</span>=<span data-x="enum-referrer-policy">ReferrerPolicy</span>] attribute DOMString <dfn attribute for="HTMLLinkElement" data-x="dom-link-referrerPolicy">referrerPolicy</dfn>;
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The ReferrerPolicy enum in the webappsec referrer policy spec needs[InvalidValueDefault, MissingValueDefault] added to it for this to be complete.

[<span>CEReactions</span>] attribute DOMString <spandata-x="dom-link-rel">rel</span>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute USVString <dfn attribute for="HTMLLinkElement"data-x="dom-link-href">href</dfn>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>="<span data-x="attr-link-crossorigin">crossorigin</span>", <span data-x="xattr-ReflectEnum">ReflectEnum</span>=<span>CORSSettingsKeywords</span>] attribute DOMString? <dfn attribute for="HTMLLinkElement"data-x="dom-link-crossOrigin">crossOrigin</dfn>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute DOMString <dfn attribute for="HTMLLinkElement"data-x="dom-link-rel">rel</dfn>;
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-link-as">as</span>;
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This could use ReflectEnum but the current keyword definitions are in the fetch spec. We could define the enum in HTML but then we might end up out of sync, or we need to define the enum in the fetch spec.

- Swap code for span- Add var to clampedMin and clampedMax- Correct plural
This is used to apply the reflection code only for the setter.
… attribute, otherwise an integer, also clean up the single double usage to actually use a decimal.
- [ReflectEnum=identifier] can be used alongside [Reflect] on DOMString and DOMString? attributes to identify the IDL enum which holds the known value keywords.Additionally, 3 new extended attributes are allowed on enums:- [InvalidValueDefault] and [InvalidValueDefault=string] sets the value to be used when the content attribute has an invalid value.- [MissingValueDefault] and [MissingValueDefault=string] sets the value to be used when the content attribute is missing.- [EmptyValueDefault] and [EmptyValueDefault=string] sets the value to be used when the content attribute is the empty string.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@lukewarlow

[8]ページ先頭

©2009-2025 Movatter.jp