Ver código fonte

HTMLMesh: do not render the script tag (#27953)

* Factor all "skipping" logics at the beginning of drawElement, include the script tag as well to the elements we skip

* Update HTMLMesh.js

Clean up.

---------

Co-authored-by: Antonio Pisano <[email protected]>
Co-authored-by: Michael Herzog <[email protected]>
Antonio Pisano 1 ano atrás
pai
commit
7295b72b2b
1 arquivos alterados com 7 adições e 9 exclusões
  1. 7 9
      examples/jsm/interactive/HTMLMesh.js

+ 7 - 9
examples/jsm/interactive/HTMLMesh.js

@@ -241,6 +241,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 ) {
@@ -258,14 +265,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();
 
@@ -280,8 +282,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;
@@ -293,8 +293,6 @@ function html2canvas( element ) {
 
 		} else {
 
-			if ( element.style.display === 'none' ) return;
-
 			const rect = element.getBoundingClientRect();
 
 			x = rect.left - offset.left - 0.5;