[whatwg/webidl] Allow a separate getter/setter attribute pair (Issue #1506)

saschanaz created an issue (whatwg/webidl#1506)

### What problem are you trying to solve?

Trusted Types added a bunch of IDL changes like this:

```webidl
  [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:

```webidl
  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.)

### Anything else?

Found while reading the result of https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/2074.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1506
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1506@github.com>

Received on Saturday, 19 July 2025 17:23:12 UTC