diff --git a/src/Clone.js b/src/Clone.js index 53e94bd..e944fad 100644 --- a/src/Clone.js +++ b/src/Clone.js @@ -346,13 +346,13 @@ const cloneCanvasContents = (canvas: HTMLCanvasElement, clonedCanvas: HTMLCanvas if (clonedCanvas) { clonedCanvas.width = canvas.width; clonedCanvas.height = canvas.height; - clonedCanvas - .getContext('2d') - .putImageData( - canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height), - 0, - 0 - ); + const ctx = canvas.getContext('2d'); + const clonedCtx = clonedCanvas.getContext('2d'); + if (ctx) { + clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0); + } else { + clonedCtx.drawImage(canvas, 0, 0); + } } } catch (e) {} }; diff --git a/tests/reftests/images/canvas.html b/tests/reftests/images/canvas.html index 2a876c4..f601d54 100644 --- a/tests/reftests/images/canvas.html +++ b/tests/reftests/images/canvas.html @@ -1,27 +1,30 @@ -
+