Change DOMState value to last static value
This commit is contained in:
parent
61be174b6e
commit
7be7cf0210
1 changed files with 5 additions and 2 deletions
7
state.js
7
state.js
|
@ -348,12 +348,13 @@ export class DOMState extends SimpleState {
|
||||||
#old
|
#old
|
||||||
#options
|
#options
|
||||||
#changedValue = false
|
#changedValue = false
|
||||||
|
#value
|
||||||
|
|
||||||
constructor(target, value, options) {
|
constructor(target, value, options) {
|
||||||
super()
|
super()
|
||||||
this.#options = options
|
this.#options = options
|
||||||
this.#old = [...value]
|
this.#old = [...value]
|
||||||
this.value = value
|
this.#value = value
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
mutationObserver.observe(target, {
|
mutationObserver.observe(target, {
|
||||||
attributes: true,
|
attributes: true,
|
||||||
|
@ -365,8 +366,10 @@ export class DOMState extends SimpleState {
|
||||||
abortRegistry.register(this, controller)
|
abortRegistry.register(this, controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get value() { return this.#old }
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
const current = [...this.value]
|
const current = [...this.#value]
|
||||||
if (current.length === this.#old.length) {
|
if (current.length === this.#old.length) {
|
||||||
for (const idx in current) {
|
for (const idx in current) {
|
||||||
if (current[idx] !== this.#old[idx]) break
|
if (current[idx] !== this.#old[idx]) break
|
||||||
|
|
Loading…
Reference in a new issue