w3ctag / design-principles

A small-but-growing set of design principles collected by the TAG while reviewing specifications
https://w3ctag.github.io/design-principles
178 stars 46 forks source link

Attributes vs method section lacks guidance on setters #415

Open cynthia opened 1 year ago

cynthia commented 1 year ago

...as title suggests.

LeaVerou commented 1 year ago

Per discussion yesterday: Getters and setters should behave like regular data properties. This means, they should not throw when read or set. If a setter needs to throw, it should be a method. Guidance should be stronger against getters throwing than setters throwing.

annevk commented 1 year ago

That's the wrong advice. Setters will pretty much always throw due to IDL. (Getters can also be made to throw by passing the wrong this, but that's indeed kind of a corner case and generally they shouldn't throw.)