refactor: revert onChanges param
This commit is contained in:
parent
060c717092
commit
d5b83ed847
2 changed files with 4 additions and 7 deletions
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue