mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-21 15:39:36 +01:00
🐛 Fix observerAdded and observerRemoved logic
This commit is contained in:
parent
f5adefbc9c
commit
421d1e9ede
@ -41,11 +41,11 @@ function connectionsChangesObserverConstructor(){
|
||||
const observer= new MutationObserver(function(mutations){
|
||||
for(const mutation of mutations){
|
||||
if(mutation.type!=="childList") continue;
|
||||
if(observerAdded(mutation.addedNodes)){
|
||||
if(observerAdded(mutation.addedNodes, true)){
|
||||
stop();
|
||||
continue;
|
||||
}
|
||||
if(observerRemoved(mutation.removedNodes))
|
||||
if(observerRemoved(mutation.removedNodes, true))
|
||||
stop();
|
||||
}
|
||||
});
|
||||
@ -113,9 +113,9 @@ function connectionsChangesObserverConstructor(){
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function observerAdded(addedNodes){
|
||||
function observerAdded(addedNodes, is_root){
|
||||
for(const element of addedNodes){
|
||||
collectChildren(element).then(observerAdded);
|
||||
if(is_root) collectChildren(element).then(observerAdded);
|
||||
if(!store.has(element)) return false;
|
||||
|
||||
const ls= store.get(element);
|
||||
@ -125,9 +125,9 @@ function connectionsChangesObserverConstructor(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function observerRemoved(removedNodes){
|
||||
function observerRemoved(removedNodes, is_root){
|
||||
for(const element of removedNodes){
|
||||
collectChildren(element).then(observerRemoved);
|
||||
if(is_root) collectChildren(element).then(observerRemoved);
|
||||
if(!store.has(element)) return false;
|
||||
|
||||
const ls= store.get(element);
|
||||
|
Loading…
Reference in New Issue
Block a user