From f8f749d32ef66d975ecaefcd3eace7ab583357cc Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 27 Mar 2023 18:55:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=BE=E7=BD=AEattribute?= =?UTF-8?q?=E4=B8=BAfalse=E6=97=B6,=E5=88=9D=E5=A7=8B=E5=80=BC=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 1f86093..532b8ff 100644 --- a/src/index.js +++ b/src/index.js @@ -228,9 +228,20 @@ export class Component extends HTMLElement { if (_name) { name = _name } - options = this.#getPropOptions(name) - this[name] = fixedValue(value, options) + value = fixedValue(value, options) + + if (options.attribute === false) { + if (value === null) { + return + } + if (value === this[name]) { + this.removeAttribute(name) + return + } + } + + this[name] = value } // 请求更新