diff --git a/index.bs b/index.bs index a55b526..e8f8cd1 100644 --- a/index.bs +++ b/index.bs @@ -1032,6 +1032,25 @@ The alternative user experience is a flash of unstyled content, which is undesir See also [[#worker-only]]. +

Expose content attributes for writable IDL attributes

+ +When designing a new *writable* IDL attribute to specify element state, +expose a corresponding content attribute unless you have a compelling reason not to. + +Providing declarative ways to manipulate state has several benefits for authors: +- It takes advantage of HTML’s [reactivity](https://en.wikipedia.org/wiki/Reactive_programming), and alleviates the need to apply changes at a specific moment in time. +- It integrates with existing DOM methods, improving learnability, whereas an API specific to the feature needs to be learned separately. +- Behaviors can be expressed reactively in libraries supporting HTML-based syntax and be handled by any library handling HTML generically. +- UI states can be addressed in CSS via simple attribute selectors rather than new pseudo-classes. +- State can be inspected and manipulated via the browser's developer tools with no need for implementing a new UI. + +
+A counterpattern to this guidance can be found in +<{input}>'s {{HTMLInputElement/indeterminate}} IDL property +which was never exposed as a content attribute making it impossible to fully update checkbox state +by modifying HTML. +
+

Keep attributes in sync

New content attributes