Skip to content

Commit ae58e88

Browse files
author
Arthur Evans
authored
Clarify API docs for PropertyAccessors mixin
1 parent 2d95217 commit ae58e88

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/mixins/property-accessors.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,18 @@
7575
* or more property accessors (getter/setter pair) that enqueue an async
7676
* (batched) `_propertiesChanged` callback.
7777
*
78-
* For basic usage of this mixin, simply declare attributes to observe via
79-
* the standard `static get observedAttributes()`, implement `_propertiesChanged`
80-
* on the class, and then call `MyClass.createPropertiesForAttributes()` once
81-
* on the class to generate property accessors for each observed attribute
82-
* prior to instancing. Last, call `this._enableProperties()` in the element's
83-
* `connectedCallback` to enable the accessors.
78+
* For basic usage of this mixin:
79+
*
80+
* - Declare attributes to observe via the standard `static get observedAttributes()`. Use
81+
* `dash-case` attribute names to represent `camelCase` property names.
82+
* - Implement the `_propertiesChanged` callback on the class.
83+
* - Call `MyClass.createPropertiesForAttributes()` **once** on the class to generate
84+
* property accessors for each observed attribute. This must be called before the first
85+
* instance is created, for example, by calling it before calling `customElements.define`.
86+
* It can also be called lazily from the element's `constructor`, as long as it's guarded so
87+
* that the call is only made once, when the first instance is created.
88+
* - Call `this._enableProperties()` in the element's `connectedCallback` to enable
89+
* the accessors.
8490
*
8591
* Any `observedAttributes` will automatically be
8692
* deserialized via `attributeChangedCallback` and set to the associated

0 commit comments

Comments
 (0)