WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
295854
[WebIDL] Add WebIDL support for [Enumerated] extended attribute, and related attributes: [MissingValueDefault], [InvalidValueDefault]
https://bugs.webkit.org/show_bug.cgi?id=295854
Summary
[WebIDL] Add WebIDL support for [Enumerated] extended attribute, and related ...
Rahim Abdi
Reported
2025-07-13 01:45:08 PDT
In .idl files, it would be helpful to simplify defining enumerated attributes to streamline getter/setter code generation (and not have to code these manually). This is particularly useful for enumerated attributes since they are limited to known values, and have two optional, special states: missing value default and invalid value default; all of these could be specified as part of an attribute's .idl declaration. For example (ignoring that these may not be truly valid values): CURRENT: [CEReactions=Needed, Reflect=aria_orientation] attribute DOMString? ariaOrientation; PROPOSED: [CEReactions=Needed, Reflect=aria_orientation, ReflectOnly=("horizontal", "vertical", "undefined"), ReflectMissing=("vertical"), ReflectInvalid=("horizontal")] attribute DOMString? ariaOrientation; Per HTML spec, DOMString and nullable DOMString (DOMString?) do not require that the attribute be enumerated however, where a content attribute is enumerated, it must be limited to known values; see DOMString and DOMString reflection algorithm:
https://html.spec.whatwg.org/#reflecting-content-attributes-in-idl-attributes
. Note: These new extended attributes are not defined in WebIDL, although they are described in WebIDL spec prose. Also, Chrome already supports them:
https://chromium.googlesource.com/chromium/src/+/HEAD/third_party/blink/renderer/bindings/IDLExtendedAttributes.md#reflectonly
.
Attachments
Add attachment
proposed patch, testcase, etc.
Rahim Abdi
Comment 1
2025-07-13 01:57:25 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/47953
Radar WebKit Bug Importer
Comment 2
2025-07-20 01:46:12 PDT
<
rdar://problem/156249490
>
Rahim Abdi
Comment 3
2025-07-20 19:20:57 PDT
New approach from PR comment on improving syntax of enumerated attributes using 'enum' IDL type:
https://github.com/WebKit/WebKit/pull/47953#pullrequestreview-3014249574
. To better support .idl definition of reflected DOMString/DOMString? attributes, the following should be added: - [Enumerated] = allowed on attributes that use [Reflect] and used to specify two or more known values for the attribute - [MissingValueDefault] = the value of the IDL attribute when the content attribute is missing:
https://html.spec.whatwg.org/#missing-value-default
- [InvalidValueDefault] = the value of the IDL attribute when the content attribute has a non-permitted value:
https://html.spec.whatwg.org/#invalid-value-default
- [EmptyValueDefault] = the value of the IDL attribute when the content attribute is present without a value, e.g., <div someAttr> (as opposed to <div someAttr="foo"> For example: [ MissingValueDefault=“Value1”, InvalidValueDefault=“Value3”, ] enum attrnameAttribute { "Value1", "Value2", "Value3" } … [Reflect=myattr, Enumerated=attrnameAttribute] attribute DOMString? myattr;
EWS
Comment 4
2025-08-02 15:00:09 PDT
Committed
298172@main
(5c150f7a3b58): <
https://commits.webkit.org/298172@main
> Reviewed commits have been landed. Closing PR #47953 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug