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() {}
/**
* @template {{'previousValue': any, 'currentValue': any}} SimpleChange
* @param {Record<string, SimpleChange>} changes
* @param {{'property': string, 'previousValue': any, 'currentValue': any}} changes
*/
onChanges(changes) {}
@ -48,7 +47,7 @@ export class WebComponent extends HTMLElement {
if (previousValue !== currentValue) {
this[property] = currentValue;
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) {
console.log("onChanges", this.querySelector("h1"));
Object.keys(changes).forEach((name) => {
console.log(name, changes[name]);
});
const { property, previousValue, currentValue } = changes;
console.log(`${property} changed`, { previousValue, currentValue });
}
get template() {