JSFiddle - React, Tailwind, and code Playground

by STHayden

HTML

<canvas id="dummy-canvas" width="250" height="250" data-src="http://i.imgur.com/w1yg6qo.jpg"></canvas>

JavaScript

var canvas = document.getElementById('dummy-canvas');
var ctx = canvas.getContext('2d');
var img = new Image();

img.onload = function() {
	// ctx.drawImage(this, 0, 0, img.width, img.height) // works
	// ctx.drawImage(this, -10, 0, img.width, img.height, 20, 10, 100, 100) // fails in edge
	ctx.drawImage(this, 0, 0, img.width + 1, img.height, 20, 10, 100, 100) // fails in edge
}

img.src = canvas.getAttribute('data-src');