Skip to content

Allow a separate getter/setter attribute pair #1506

@saschanaz

Description

@saschanaz

What problem are you trying to solve?

Trusted Types added a bunch of IDL changes like this:

[CEReactions] attribute (TrustedHTML or [LegacyNullToEmptyString] DOMString) innerHTML;

This is to assign TrustedHTML object, while the getter will only ever return a DOMString. The intention is not clear from the IDL until you read the prose.

What solutions exist today?

Just use the most permissive type to allow both getter and setter requirements 😞

How would you solve it?

Something like the following would be nicer:

attribute getter DOMString innerHTML;
[CEReactions] attribute setter (TrustedHTML or [LegacyNullToEmptyString] DOMString) innerHTML;

Although the syntax is sad - it allows invalid setup like having a setter only.

[CEReactions, GetterType=DOMString]
attribute (TrustedHTML or [LegacyNullToEmptyString] DOMString) innerHTML;

Something like this could work too, but I'm not very happy to put types into extended attribute value 🤔

Anything else?

Found while reading the result of microsoft/TypeScript-DOM-lib-generator#2074.

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions