Skip to content

Commit

Permalink
Update canvas-renderer.ts (#2004)
Browse files Browse the repository at this point in the history
* Update canvas-renderer.ts

Fixed an issue were a page wouldn't render.

Line 581 (now 582) threw exception: "Uncaught (in promise) DOMException: Failed to execute 'createPattern' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0."

* Update canvas-renderer.ts
  • Loading branch information
RickBetting authored and niklasvh committed Sep 22, 2019
1 parent ee3ca35 commit d4b5896
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/render/canvas/canvas-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,10 @@ export class CanvasRenderer {

ctx.fillStyle = gradient;
ctx.fillRect(0, 0, width, height);
const pattern = this.ctx.createPattern(canvas, 'repeat') as CanvasPattern;
this.renderRepeat(path, pattern, x, y);
if ((width > 0) && (height > 0)) {
const pattern = this.ctx.createPattern(canvas, 'repeat') as CanvasPattern;
this.renderRepeat(path, pattern, x, y);
}
} else if (isRadialGradient(backgroundImage)) {
const [path, left, top, width, height] = calculateBackgroundRendering(container, index, [
null,
Expand Down

0 comments on commit d4b5896

Please sign in to comment.