From 9a3c6926dc771e3142978d1bbf1f175ee046bd2f Mon Sep 17 00:00:00 2001 From: Chad Petersen Date: Tue, 6 Sep 2022 15:56:20 -0600 Subject: [PATCH] Updated tests for new bound vs bounds function. --- src/css/layout/__mocks__/bounds.ts | 4 ++++ src/render/canvas/canvas-renderer.ts | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/css/layout/__mocks__/bounds.ts b/src/css/layout/__mocks__/bounds.ts index 08c022c..15f9186 100644 --- a/src/css/layout/__mocks__/bounds.ts +++ b/src/css/layout/__mocks__/bounds.ts @@ -2,3 +2,7 @@ export const {Bounds} = jest.requireActual('../bounds'); export const parseBounds = (): typeof Bounds[] => { return [new Bounds(0, 0, 200, 50)]; }; + +export const parseBound = (): typeof Bounds => { + return new Bounds(0, 0, 200, 50); +}; diff --git a/src/render/canvas/canvas-renderer.ts b/src/render/canvas/canvas-renderer.ts index c063fe9..c100574 100644 --- a/src/render/canvas/canvas-renderer.ts +++ b/src/render/canvas/canvas-renderer.ts @@ -617,11 +617,13 @@ export class CanvasRenderer extends Renderer { ]); areas.forEach((area) => { const [path, x, y, width, height] = area; - const pattern = this.ctx.createPattern( - this.resizeImage(image!, width, height), - 'repeat' - ) as CanvasPattern; - this.renderRepeat(path, pattern, x, y); + if (image) { + const pattern = this.ctx.createPattern( + this.resizeImage(image, width, height), + 'repeat' + ) as CanvasPattern; + this.renderRepeat(path, pattern, x, y); + } }); } } else if (isLinearGradient(backgroundImage)) {