Quellcode durchsuchen

make sure size is always defined

Gildas vor 7 Jahren
Ursprung
Commit
944a29efa2
1 geänderte Dateien mit 3 neuen und 5 gelöschten Zeilen
  1. 3 5
      lib/single-file/util/doc-helper.js

+ 3 - 5
lib/single-file/util/doc-helper.js

@@ -336,11 +336,9 @@ this.docHelper = this.docHelper || (() => {
 			} else {
 				borderLeft = borderRight = borderTop = borderBottom = 0;
 			}
-			pxWidth = imageElement.clientWidth - paddingLeft - paddingRight - borderLeft - borderRight;
-			pxHeight = imageElement.clientHeight - paddingTop - paddingBottom - borderTop - borderBottom;
-			if (pxWidth >= 0 && pxHeight >= 0 && paddingLeft >= 0 && paddingRight >= 0 && paddingTop >= 0 && paddingBottom >= 0 && borderLeft >= 0 && borderRight >= 0 && borderTop >= 0 && borderBottom >= 0) {
-				return { pxWidth, pxHeight };
-			}
+			pxWidth = Math.max(0, imageElement.clientWidth - paddingLeft - paddingRight - borderLeft - borderRight);
+			pxHeight = Math.max(0, imageElement.clientHeight - paddingTop - paddingBottom - borderTop - borderBottom);
+			return { pxWidth, pxHeight };
 		}
 	}