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 21, 2024
1 parent 7052c20 commit 1829cde
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/HTMLMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ 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 +271,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 +288,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 +299,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 1829cde

Please sign in to comment.