refactor: revert onChanges param

This commit is contained in:
Ayo 2023-09-17 20:35:21 +02:00
parent 060c717092
commit d5b83ed847
2 changed files with 4 additions and 7 deletions

View file

@ -28,8 +28,7 @@ export class WebComponent extends HTMLElement {
onInit() {} onInit() {}
/** /**
* @template {{'previousValue': any, 'currentValue': any}} SimpleChange * @param {{'property': string, 'previousValue': any, 'currentValue': any}} changes
* @param {Record<string, SimpleChange>} changes
*/ */
onChanges(changes) {} onChanges(changes) {}
@ -48,7 +47,7 @@ export class WebComponent extends HTMLElement {
if (previousValue !== currentValue) { if (previousValue !== currentValue) {
this[property] = currentValue; this[property] = currentValue;
this.render(); this.render();
this.onChanges({ [property]: { previousValue, currentValue } }); this.onChanges({ property, previousValue, currentValue });
} }
} }

View file

@ -16,10 +16,8 @@ export class HelloWorld extends WebComponent {
} }
onChanges(changes) { onChanges(changes) {
console.log("onChanges", this.querySelector("h1")); const { property, previousValue, currentValue } = changes;
Object.keys(changes).forEach((name) => { console.log(`${property} changed`, { previousValue, currentValue });
console.log(name, changes[name]);
});
} }
get template() { get template() {