diff --git a/src/render/canvas/canvas-renderer.ts b/src/render/canvas/canvas-renderer.ts index ae72b45..05408e0 100644 --- a/src/render/canvas/canvas-renderer.ts +++ b/src/render/canvas/canvas-renderer.ts @@ -541,8 +541,8 @@ export class CanvasRenderer { } const canvas = (this.canvas.ownerDocument as Document).createElement('canvas'); - canvas.width = width; - canvas.height = height; + canvas.width = Math.max(1, width); + canvas.height = Math.max(1, height); const ctx = canvas.getContext('2d') as CanvasRenderingContext2D; ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, width, height); return canvas; diff --git a/tests/assets/bg-sliver.png b/tests/assets/bg-sliver.png new file mode 100644 index 0000000..06ed91f Binary files /dev/null and b/tests/assets/bg-sliver.png differ diff --git a/tests/reftests/background/size.html b/tests/reftests/background/size.html index 6cdf0fc..d551136 100644 --- a/tests/reftests/background/size.html +++ b/tests/reftests/background/size.html @@ -9,6 +9,10 @@ display: block; background:url("../../assets/image.jpg") center center; } + .sliver div { + background:url("../../assets/bg-sliver.png") center center; + background-size: 650px auto; + } .vertical { float: right; @@ -57,5 +61,8 @@
+
+
+