Add "newer" map to track replaced reactive elements
This commit is contained in:
parent
12daec85e6
commit
21e5bdbba4
1 changed files with 4 additions and 0 deletions
|
@ -134,6 +134,9 @@ class ReplacedEvent extends Event {
|
|||
}
|
||||
}
|
||||
|
||||
/** @type {WeakMap<Text|Element,Text|Element>} */
|
||||
export const newer = new WeakMap()
|
||||
|
||||
/**
|
||||
* @param {Observable} observable
|
||||
* @return {Element|Text}
|
||||
|
@ -147,6 +150,7 @@ export const reactiveElement = observable => {
|
|||
const element = ref.deref()
|
||||
if (element.dispatchEvent(new ReplaceEvent(next)))
|
||||
element.replaceWith(next)
|
||||
newer.set(this, next)
|
||||
element.dispatchEvent(new ReplacedEvent(next))
|
||||
}, {once: true})
|
||||
return element
|
||||
|
|
Loading…
Reference in a new issue