Created
November 7, 2017 01:14
-
-
Save nektro/84654b5183ddd1ccb7489607239c982d to your computer and use it in GitHub Desktop.
Edge and Safari Polyfill for createImageBitmap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Safari and Edge polyfill for createImageBitmap | |
* https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap | |
*/ | |
if (!('createImageBitmap' in window)) { | |
window.createImageBitmap = async function(blob) { | |
return new Promise((resolve,reject) => { | |
let img = document.createElement('img'); | |
img.addEventListener('load', function() { | |
resolve(this); | |
}); | |
img.src = URL.createObjectURL(blob); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And I took it a bit smaller