From 38749bc4b6a861f778a915491fc7d84fea6e1a2f Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Thu, 21 Dec 2017 23:31:55 +0800 Subject: [PATCH] Fix canvas rendering on Chrome --- src/Window.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Window.js b/src/Window.js index 420939a..9a49ca4 100644 --- a/src/Window.js +++ b/src/Window.js @@ -97,16 +97,6 @@ export const renderElement = ( } return resourceLoader.ready().then(imageStore => { - if (options.removeContainer === true) { - if (container.parentNode) { - container.parentNode.removeChild(container); - } else if (__DEV__) { - logger.log( - `Cannot detach cloned iframe as it is not in the DOM anymore` - ); - } - } - const fontMetrics = new FontMetrics(clonedDocument); if (__DEV__) { logger.log(`Starting renderer`); @@ -133,7 +123,18 @@ export const renderElement = ( ); } else { const renderer = new Renderer(options.target, renderOptions); - return renderer.render(stack); + const canvas = renderer.render(stack); + if (options.removeContainer === true) { + if (container.parentNode) { + container.parentNode.removeChild(container); + } else if (__DEV__) { + logger.log( + `Cannot detach cloned iframe as it is not in the DOM anymore` + ); + } + } + + return canvas; } }); })