Fix canvas rendering on Chrome

This commit is contained in:
Niklas von Hertzen 2017-12-21 23:31:55 +08:00
parent e1d6b4c76f
commit 38749bc4b6

View File

@ -97,16 +97,6 @@ export const renderElement = (
} }
return resourceLoader.ready().then(imageStore => { 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); const fontMetrics = new FontMetrics(clonedDocument);
if (__DEV__) { if (__DEV__) {
logger.log(`Starting renderer`); logger.log(`Starting renderer`);
@ -133,7 +123,18 @@ export const renderElement = (
); );
} else { } else {
const renderer = new Renderer(options.target, renderOptions); 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;
} }
}); });
}) })