Skip to content

Remove required and [EnforceRange] attributes from readonly dictionaries - #559

Open
twiss wants to merge 1 commit into
mainfrom
no-readonly-required-enforcerange
Open

Remove required and [EnforceRange] attributes from readonly dictionaries#559
twiss wants to merge 1 commit into
mainfrom
no-readonly-required-enforcerange

Conversation

@twiss

@twiss twiss commented Aug 20, 2026

Copy link
Copy Markdown
Member

Remove the required and [EnforceRange] attributes of all properties of KeyAlgorithm dictionaries, which are only used on the algorithm property of CryptoKey, which is readonly.

WebIDL says:

Note that specifying dictionary members as required only has an observable effect when converting other representations of dictionaries (like a JavaScript value supplied as an argument to an operation) to an IDL dictionary. Specification authors should leave the members optional in all other cases, including when a dictionary type is used solely as the return type of operations.

and:

A type annotated with the [EnforceRange] extended attribute must not appear in a read only attribute.

(even though the attributes themselves are not readonly, the algorithm attribute of CryptoKey is).


Preview | Diff

@twiss
twiss requested a review from annevk August 20, 2026 14:11

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have not verified that these dictionaries are only used as return values.

(I also think we should change Web IDL at some point so required is fine for return values as it's kinda useful there for code generation and indicating the member will be present.)

@twiss

twiss commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

Right, sorry, I saw your other comment too late.

It's a bit out of scope here but maybe it would be sensible to flip the defaults, and have optional and [Modulo]/[Truncate] or something like that instead (as also suggested in #429 (comment))? That way, you can still assume that returned dictionaries behave "sensibly" by default, without having to annotate all of them. It might cause a lot of churn for dictionaries that do get passed in, though.

Edit: created whatwg/webidl#1628 and whatwg/webidl#1629 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants