Skip to content

Commit

Permalink
HTMLMesh: do not render the script tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Pisano committed Mar 20, 2024
1 parent 7052c20 commit 61a2486
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/HTMLMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ function html2canvas( element ) {

function drawElement( element, style ) {

// Do not render invisible elements, comments and scripts.
if (element.nodeType === Node.COMMENT_NODE || element.nodeName === 'SCRIPT' || (element.style && element.style.display === 'none')) {
return;
}

let x = 0, y = 0, width = 0, height = 0;

if ( element.nodeType === Node.TEXT_NODE ) {
Expand All @@ -264,14 +269,9 @@ function html2canvas( element ) {

drawText( style, x, y, element.nodeValue.trim() );

} else if ( element.nodeType === Node.COMMENT_NODE ) {

return;

} else if ( element instanceof HTMLCanvasElement ) {

// Canvas element
if ( element.style.display === 'none' ) return;

const rect = element.getBoundingClientRect();

Expand All @@ -286,8 +286,6 @@ function html2canvas( element ) {

} else if ( element instanceof HTMLImageElement ) {

if ( element.style.display === 'none' ) return;

const rect = element.getBoundingClientRect();

x = rect.left - offset.left - 0.5;
Expand All @@ -299,8 +297,6 @@ function html2canvas( element ) {

} else {

if ( element.style.display === 'none' ) return;

const rect = element.getBoundingClientRect();

x = rect.left - offset.left - 0.5;
Expand Down

0 comments on commit 61a2486

Please sign in to comment.