Skip to content

Commit

Permalink
fix: zero size iframe rendering (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
garaboncias authored and niklasvh committed Jun 18, 2019
1 parent 61f4819 commit 81dcf7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/dom/replaced-elements/iframe-element-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class IFrameElementContainer extends ElementContainer {
constructor(iframe: HTMLIFrameElement) {
super(iframe);
this.src = iframe.src;
this.width = parseInt(iframe.width, 10);
this.height = parseInt(iframe.height, 10);
this.width = parseInt(iframe.width, 10) || 0;
this.height = parseInt(iframe.height, 10) || 0;
this.backgroundColor = this.styles.backgroundColor;
try {
if (
Expand Down
24 changes: 13 additions & 11 deletions src/render/canvas/canvas-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,19 @@ export class CanvasRenderer {
});

const canvas = await iframeRenderer.render(container.tree);
this.ctx.drawImage(
canvas,
0,
0,
container.width,
container.width,
container.bounds.left,
container.bounds.top,
container.bounds.width,
container.bounds.height
);
if (container.width && container.height) {
this.ctx.drawImage(
canvas,
0,
0,
container.width,
container.height,
container.bounds.left,
container.bounds.top,
container.bounds.width,
container.bounds.height
);
}
}

if (container instanceof InputElementContainer) {
Expand Down

0 comments on commit 81dcf7b

Please sign in to comment.