From 12b4417a94d5296afb04b0c623d2bf6a1761bb23 Mon Sep 17 00:00:00 2001 From: yutent Date: Fri, 22 Sep 2023 16:16:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=B9=E9=94=99=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 3316c42..8a61ca7 100644 --- a/src/index.js +++ b/src/index.js @@ -301,7 +301,7 @@ export class Component extends HTMLElement { * @param value */ #prop2attr(name, value) { - let options = this.#getPropOptions(name) + let options = this.#getPropOptions(name) || {} let attrName = options.attrName if (options.attribute === false) { @@ -344,15 +344,18 @@ export class Component extends HTMLElement { propName = camelize(name) options = this.#getPropOptions(propName) - value = fixedValue(value, options) - if (options.attribute === false) { - if (value === null) { - return - } - if (value === this[propName]) { - this.removeAttribute(name) - return + if (options) { + value = fixedValue(value, options) + + if (options.attribute === false) { + if (value === null) { + return + } + if (value === this[propName]) { + this.removeAttribute(name) + return + } } }