Skip to content

Commit

Permalink
fix: Made sure that remove() is not called directly from node
Browse files Browse the repository at this point in the history
  • Loading branch information
cure53 committed Jul 4, 2024
1 parent 00fc06c commit 6e03334
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion dist/purify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.cjs.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/purify.es.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ function createDOMPurify() {
} = window;
const ElementPrototype = Element.prototype;
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
const remove = lookupGetter(ElementPrototype, 'remove');
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
Expand Down Expand Up @@ -830,7 +831,7 @@ function createDOMPurify() {
// eslint-disable-next-line unicorn/prefer-dom-node-remove
getParentNode(node).removeChild(node);
} catch (_) {
node.remove();
remove(node);
}
};

Expand Down
2 changes: 1 addition & 1 deletion dist/purify.es.mjs.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/purify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function createDOMPurify(window = getGlobal()) {
const ElementPrototype = Element.prototype;

const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
const remove = lookupGetter(ElementPrototype, 'remove');
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
Expand Down Expand Up @@ -809,7 +810,7 @@ function createDOMPurify(window = getGlobal()) {
// eslint-disable-next-line unicorn/prefer-dom-node-remove
getParentNode(node).removeChild(node);
} catch (_) {
node.remove();
remove(node);
}
};

Expand Down

0 comments on commit 6e03334

Please sign in to comment.