feat: only call onChanges when previousValue !== currentValue
This commit is contained in:
parent
8cfd286598
commit
0ba7738da1
2 changed files with 5 additions and 2 deletions
|
@ -23,10 +23,9 @@ export class WebComponent extends HTMLElement {
|
||||||
attributeChangedCallback(property, previousValue, currentValue) {
|
attributeChangedCallback(property, previousValue, currentValue) {
|
||||||
if (previousValue !== currentValue) {
|
if (previousValue !== currentValue) {
|
||||||
this[property] = currentValue;
|
this[property] = currentValue;
|
||||||
|
this.onChanges({ property, previousValue, currentValue });
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onChanges({ property, previousValue, currentValue });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
helloWorld.setAttribute("emotion", "excited");
|
helloWorld.setAttribute("emotion", "excited");
|
||||||
}, 2500);
|
}, 2500);
|
||||||
|
|
||||||
|
helloWorld.addEventListener("click", () => {
|
||||||
|
helloWorld.setAttribute("name", "Clicked");
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue