|
@@ -119,8 +119,8 @@ function onMutate(mutations) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- let addedNodes = []
|
|
|
|
- let removedNodes = []
|
|
|
|
|
|
+ let addedNodes = new Set
|
|
|
|
+ let removedNodes = new Set
|
|
let addedAttributes = new Map
|
|
let addedAttributes = new Map
|
|
let removedAttributes = new Map
|
|
let removedAttributes = new Map
|
|
|
|
|
|
@@ -128,8 +128,8 @@ function onMutate(mutations) {
|
|
if (mutations[i].target._x_ignoreMutationObserver) continue
|
|
if (mutations[i].target._x_ignoreMutationObserver) continue
|
|
|
|
|
|
if (mutations[i].type === 'childList') {
|
|
if (mutations[i].type === 'childList') {
|
|
- mutations[i].addedNodes.forEach(node => node.nodeType === 1 && addedNodes.push(node))
|
|
|
|
- mutations[i].removedNodes.forEach(node => node.nodeType === 1 && removedNodes.push(node))
|
|
|
|
|
|
+ mutations[i].addedNodes.forEach(node => node.nodeType === 1 && addedNodes.add(node))
|
|
|
|
+ mutations[i].removedNodes.forEach(node => node.nodeType === 1 && removedNodes.add(node))
|
|
}
|
|
}
|
|
|
|
|
|
if (mutations[i].type === 'attributes') {
|
|
if (mutations[i].type === 'attributes') {
|
|
@@ -171,10 +171,11 @@ function onMutate(mutations) {
|
|
onAttributeAddeds.forEach(i => i(el, attrs))
|
|
onAttributeAddeds.forEach(i => i(el, attrs))
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ console.log(removedNodes, addedNodes)
|
|
for (let node of removedNodes) {
|
|
for (let node of removedNodes) {
|
|
// If an element gets moved on a page, it's registered
|
|
// If an element gets moved on a page, it's registered
|
|
// as both an "add" and "remove", so we want to skip those.
|
|
// as both an "add" and "remove", so we want to skip those.
|
|
- if (addedNodes.includes(node)) continue
|
|
|
|
|
|
+ if (addedNodes.has(node)) continue
|
|
|
|
|
|
onElRemoveds.forEach(i => i(node))
|
|
onElRemoveds.forEach(i => i(node))
|
|
|
|
|