From 322140bbec0a4bfe91b229a4764b7b5b9eb7d15d Mon Sep 17 00:00:00 2001 From: hrj Date: Sun, 26 Jun 2016 19:48:11 +0530 Subject: [PATCH] poly fill for toBlob() --- src/flif-post.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/flif-post.js b/src/flif-post.js index 0a96677..c094595 100644 --- a/src/flif-post.js +++ b/src/flif-post.js @@ -151,6 +151,24 @@ document.addEventListener("DOMContentLoaded", function() { }); } + // Poly-fill for toBlob, inspired by MDN docs + if (!HTMLCanvasElement.prototype.toBlob) { + Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', { + value: function (callback, type, quality) { + + var binStr = atob(this.toDataURL(type, quality).split(',')[1] ), + len = binStr.length, + arr = new Uint8Array(len); + + for (var i=0; i