isMutationBelongsToElement function shouldn't return true if some of the ancestors of the passed element were added or deleted, only if the element itself

This commit is contained in:
Kanstantsin_Vikhor 2024-02-28 11:02:47 +04:00
parent 040760c6b3
commit 439adcd410

View file

@ -12,11 +12,11 @@ export function isMutationBelongsToElement(mutationRecord: MutationRecord, eleme
}
if (type === 'childList') {
const elementAddedItself = Array.from(addedNodes).some(node => node.contains(element));
const elementAddedItself = Array.from(addedNodes).some(node => node === element);
if (elementAddedItself) {
return true;
}
const elementRemovedItself = Array.from(removedNodes).some(node => node.contains(element));
const elementRemovedItself = Array.from(removedNodes).some(node => node === element);
if (elementRemovedItself) {
return true;
}