From 4f767a6ab6ab7bce17cf462a76e2cfb51cc4c8dc Mon Sep 17 00:00:00 2001 From: Nicolas D'Amours Date: Thu, 9 Nov 2023 11:47:59 -0500 Subject: [PATCH] [BUGFIX] added fix from #2982 Added prepare script. --- package.json | 3 ++- src/render/background.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cefd4369a..901ac4943 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,8 @@ "karma": "ts-node tests/karma", "watch": "rollup -c rollup.config.ts -w", "watch:unittest": "mocha --require ts-node/register --watch-extensions ts -w src/**/__tests__/*.ts", - "start": "ts-node tests/server --port=8080 --cors=8081" + "start": "ts-node tests/server --port=8080 --cors=8081", + "prepare": "npm run build" }, "homepage": "https://html2canvas.hertzen.com", "license": "MIT", diff --git a/src/render/background.ts b/src/render/background.ts index 6e0e877ea..dd92d171a 100644 --- a/src/render/background.ts +++ b/src/render/background.ts @@ -58,7 +58,7 @@ export const calculateBackgroundRendering = ( backgroundPositioningArea ); - const [sizeWidth, sizeHeight] = backgroundImageSize; + let [sizeWidth, sizeHeight] = backgroundImageSize; const position = getAbsoluteValueForTuple( getBackgroundValueForIndex(container.styles.backgroundPosition, index), @@ -77,6 +77,9 @@ export const calculateBackgroundRendering = ( const offsetX = Math.round(backgroundPositioningArea.left + position[0]); const offsetY = Math.round(backgroundPositioningArea.top + position[1]); + sizeWidth = Math.max(1,sizeWidth) + sizeHeight = Math.max(1,sizeHeight) + return [path, offsetX, offsetY, sizeWidth, sizeHeight]; };