This commit is contained in:
Ilya Kantor 2020-12-05 23:02:20 +03:00
parent 63d0f055fc
commit ec4dcb279a

View file

@ -149,7 +149,7 @@ The `connectedCallback` triggers when the element is added to the document. Not
In the current implementation of `<time-formatted>`, after the element is rendered, further attribute changes don't have any effect. That's strange for an HTML element. Usually, when we change an attribute, like `a.href`, we expect the change to be immediately visible. So let's fix this. In the current implementation of `<time-formatted>`, after the element is rendered, further attribute changes don't have any effect. That's strange for an HTML element. Usually, when we change an attribute, like `a.href`, we expect the change to be immediately visible. So let's fix this.
We can observe attributes by providing their list in `observedAttributes()` static getter. For such attributes, `attributeChangedCallback` is called when they are modified. It doesn't trigger for an attribute for performance reasons. We can observe attributes by providing their list in `observedAttributes()` static getter. For such attributes, `attributeChangedCallback` is called when they are modified. It doesn't trigger for other, unlisted attributes (that's for performance reasons).
Here's a new `<time-formatted>`, that auto-updates when attributes change: Here's a new `<time-formatted>`, that auto-updates when attributes change: