1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-21 23:39:37 +01:00

🐛 Fix observerAdded and observerRemoved logic

This commit is contained in:
Jan Andrle 2023-08-26 17:47:46 +02:00
parent f5adefbc9c
commit 421d1e9ede
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB

View File

@ -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);