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)) {