Skip to content

Commit

Permalink
Filter out <script> elements to keep DOM static
Browse files Browse the repository at this point in the history
  • Loading branch information
zm-cttae authored Jan 19, 2023
1 parent a159648 commit a6ce137
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dom-to-image-more.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
function cloneNode(node, filter, parentComputedStyles, ownerWindow) {
if (
node === sandbox ||
util.isHTMLScriptElement(node) ||
(parentComputedStyles !== null && filter && !filter(node))
) {
return Promise.resolve();
Expand Down Expand Up @@ -506,6 +507,7 @@
isShadowSlotElement: isShadowSlotElement,
isHTMLInputElement: isHTMLInputElement,
isHTMLImageElement: isHTMLImageElement,
isHTMLScriptElement: isHTMLScriptElement,
isHTMLTextAreaElement: isHTMLTextAreaElement,
isSVGElement: isSVGElement,
isSVGRectElement: isSVGRectElement,
Expand Down Expand Up @@ -556,6 +558,10 @@
return value instanceof getWindow(value).HTMLInputElement;
}

function isHTMLScriptElement(value) {
return value instanceof getWindow(value).HTMLScriptElement;
}

function isSVGElement(value) {
return value instanceof getWindow(value).SVGElement;
}
Expand Down

0 comments on commit a6ce137

Please sign in to comment.