Просмотр исходного кода

make sure size is always defined

Gildas 7 лет назад
Родитель
Сommit
944a29efa2
1 измененных файлов с 3 добавлено и 5 удалено
  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 };
 		}
 	}