From d2ccaa5c3d3b8bdd3ba3e81af264aaa78d4412e5 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 23 Mar 2023 19:42:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dnoop=E6=9C=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 10 ++++++---- src/utils.js | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) 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)