diff --git a/src/index.js b/src/index.js index efa07b2..eb3ed7d 100644 --- a/src/index.js +++ b/src/index.js @@ -56,7 +56,7 @@ export class Component extends HTMLElement { return } this[key] = value - this.#requestUpdate(name, oldValue) + this.$requestUpdate(name, oldValue) if (options.observer) { options.observer.call(this, value, oldValue) } @@ -203,9 +203,11 @@ export class Component extends HTMLElement { } // 请求更新 - #requestUpdate(name, oldValue) { - this[__changed_props__].set(name, this[name]) - this[__prop2attr__](name, this[name]) + $requestUpdate(name, oldValue) { + if (name !== void 0) { + this[__changed_props__].set(name, this[name]) + this[__prop2attr__](name, this[name]) + } if (this[__pending__] === false) { this[__pending__] = true diff --git a/src/utils.js b/src/utils.js index d24a5f7..02c8848 100644 --- a/src/utils.js +++ b/src/utils.js @@ -4,6 +4,8 @@ * @date 2023/03/07 22:11:30 */ +function noop() {} + export function $(selector, container) { if (container) { return container.querySelector(selector)