Not sure why the load object is so different. In Firefox you can use target
or one of the other properties.
Properties in Firefox that contain the element (these all seem to be null in Chrome):
explicitOriginalTarget: <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD…">
originalTarget: <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD…">
srcElement: <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD…">
target: <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD…">
I renamed the param to event
.
preloadImg(datauri) {
const img = new Image();
return new Promise((resolve) => {
img.onload = (event) => {
const imgElement = event.path ? event.path[0] : event.target;
resolve(imgElement);
};
img.src = datauri;
});
}