修复设置attribute为false时,初始值不生效的bug

pull/1/head
yutent 2023-03-27 18:55:47 +08:00
parent 8770c32e5b
commit f8f749d32e
1 changed files with 13 additions and 2 deletions

View File

@ -228,9 +228,20 @@ export class Component extends HTMLElement {
if (_name) { if (_name) {
name = _name name = _name
} }
options = this.#getPropOptions(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
} }
// 请求更新 // 请求更新