Skip to content

Commit addae2f

Browse files
authored
Merge pull request #113 from github/docs-clarify-using-defineobservedattributes-usage
docs: clarify using defineObservedAttributes usage
2 parents 7b56c00 + 33fb4e7 commit addae2f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

docs/_guide/attrs.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ data-name ".*": Will set the value of `name`
187187

188188
### What about without Decorators?
189189

190-
If you're not using decorators, then you won't be able to use the `@attr` decorator, but there is still a way to achieve the same result. Under the hood `@attr` simply tags a field, but `initializeAttrs` does all of the logic.
190+
If you're not using decorators, then you won't be able to use the `@attr` decorator, but there is still a way to achieve the same result. Under the hood `@attr` simply tags a field, but `initializeAttrs` and `defineObservedAttributes` do all of the logic.
191191

192-
Calling `initializeAttrs` in your connected callback, with the list of properties you'd like to initialize can achieve the same result. The class fields can still be defined in your class, and they'll be overridden as described above. For example:
192+
Calling `initializeAttrs` in your connected callback, with the list of properties you'd like to initialize, and calling `defineObservedAttributes` with the class, can achieve the same result as `@attr`. The class fields can still be defined in your class, and they'll be overridden as described above. For example:
193193

194194
```js
195-
import {initializeAttrs} from '@github/catalyst'
195+
import {initializeAttrs, defineObservedAttributes} from '@github/catalyst'
196196

197197
class HelloWorldElement extends HTMLElement {
198198
foo = 1
@@ -202,6 +202,7 @@ class HelloWorldElement extends HTMLElement {
202202
}
203203

204204
}
205+
defineObservedAttributes(HelloWorldElement, ['foo'])
205206
```
206207

207208
This example is functionally identical to:

0 commit comments

Comments
 (0)