Skip to content

Commit

Permalink
fix: Fix the error
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcellPerger1 committed Feb 26, 2024
1 parent 0a73349 commit 4c013cf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/adblocker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
var rm = {
elem(/** @type {HTMLElement} */elem) {
if(!shouldIgnore(elem)) {
removedElems.add([elem, elem.parentElement]);
elem.remove()
removedElems.add(elem);
}
},
list(/** @type {HTMLElement[]} */elems) {
Expand All @@ -40,7 +40,7 @@
}
}
};
var /** @type {Set<HTMLElement>} */ removedElems = new Set;
var /** @type {Set<[HTMLElement, HTMLElement]>} */ removedElems = new Set;
var handledElems /** @type {Set<HTMLElement>} */ = new Set;
for (let [name, args] of Object.entries(what)) {
// don't try to use the 'ignore' property as a thing to block
Expand All @@ -50,12 +50,11 @@
}
}
}
for(let elem of removedElems) {
for(let [elem, parent] of removedElems) {
if(handledElems.has(elem)) {
continue; // already handled
}
handledElems.add(elem);
let parent = elem.parentElement;
if(!parent.isConnected) {
// (indirect) parent has been deleted so don't do anything here,
// instead go from the parent (which will also be in the Set)
Expand Down

0 comments on commit 4c013cf

Please sign in to comment.