Compare strings in component attributes
This commit is contained in:
parent
7febebce65
commit
b7bb093a0c
1 changed files with 2 additions and 2 deletions
4
state.js
4
state.js
|
@ -207,7 +207,7 @@ const attributeObserver = new MutationObserver(mutations => {
|
||||||
for (const {type, target, attributeName: name} of mutations) {
|
for (const {type, target, attributeName: name} of mutations) {
|
||||||
if (type == "attributes") {
|
if (type == "attributes") {
|
||||||
const next = target.getAttribute(name)
|
const next = target.getAttribute(name)
|
||||||
if (target.state.proxy[name] !== next)
|
if (String(target.state.proxy[name]) !== next)
|
||||||
target.state.proxy[name] = next
|
target.state.proxy[name] = next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ export const component = (generator, name) => {
|
||||||
this.state = new State(Object.fromEntries([...this.attributes].map(attribute => [attribute.name, attribute.value])))
|
this.state = new State(Object.fromEntries([...this.attributes].map(attribute => [attribute.name, attribute.value])))
|
||||||
this.state.addEventListener("change", event => {
|
this.state.addEventListener("change", event => {
|
||||||
for (const [name, value] of event.changes) {
|
for (const [name, value] of event.changes) {
|
||||||
if (this.getAttribute(name) !== value)
|
if (this.getAttribute(name) !== String(value))
|
||||||
this.setAttribute(name, value)
|
this.setAttribute(name, value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue