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) {
|
||||
if (previousValue !== currentValue) {
|
||||
this[property] = currentValue;
|
||||
this.onChanges({ property, previousValue, currentValue });
|
||||
this.render();
|
||||
}
|
||||
|
||||
this.onChanges({ property, previousValue, currentValue });
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
setTimeout(() => {
|
||||
helloWorld.setAttribute("emotion", "excited");
|
||||
}, 2500);
|
||||
|
||||
helloWorld.addEventListener("click", () => {
|
||||
helloWorld.setAttribute("name", "Clicked");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue