增加容错处理
parent
4ebf74f40f
commit
12b4417a94
21
src/index.js
21
src/index.js
|
@ -301,7 +301,7 @@ export class Component extends HTMLElement {
|
||||||
* @param value<String|Boolean|Number>
|
* @param value<String|Boolean|Number>
|
||||||
*/
|
*/
|
||||||
#prop2attr(name, value) {
|
#prop2attr(name, value) {
|
||||||
let options = this.#getPropOptions(name)
|
let options = this.#getPropOptions(name) || {}
|
||||||
let attrName = options.attrName
|
let attrName = options.attrName
|
||||||
|
|
||||||
if (options.attribute === false) {
|
if (options.attribute === false) {
|
||||||
|
@ -344,15 +344,18 @@ export class Component extends HTMLElement {
|
||||||
propName = camelize(name)
|
propName = camelize(name)
|
||||||
|
|
||||||
options = this.#getPropOptions(propName)
|
options = this.#getPropOptions(propName)
|
||||||
value = fixedValue(value, options)
|
|
||||||
|
|
||||||
if (options.attribute === false) {
|
if (options) {
|
||||||
if (value === null) {
|
value = fixedValue(value, options)
|
||||||
return
|
|
||||||
}
|
if (options.attribute === false) {
|
||||||
if (value === this[propName]) {
|
if (value === null) {
|
||||||
this.removeAttribute(name)
|
return
|
||||||
return
|
}
|
||||||
|
if (value === this[propName]) {
|
||||||
|
this.removeAttribute(name)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue