Re: [heycam/webidl] Extending an interface with boolean attribute with default value false (#880)

Attributes can't have default values in Web IDL. The customary way to specify something like this is to have the `SpeechSynthesisUtterance` object possess a "SSML flag" internal slot that defaults to false when an object is first created. The getter steps of the `ssml` attribute would be to return the value of this flag, and the setter steps would be to set the "SSML flag".

That being said, the API design looks pretty odd. In particular, forcing users to modify the `ssml` and `text` attributes separately could contribute to a temporary state of inconsistency between `ssml` and `text`, which IMO would be poor design. (E.g., `text` has been set to SSML text while `ssml` is still false.) In response to this, I'd propose making `ssml` settable through the constructor but immutable otherwise. In fact, if I were to design the API, I'd make all of these properties (`text`, `volume`, etc.) readonly; but if that's no longer possible, making `ssml` immutable and only settable through the constructor is the next best thing.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/880#issuecomment-629372474

Received on Friday, 15 May 2020 17:02:05 UTC