Update poylfills (fixes #662)
This commit is contained in:
parent
fce248810b
commit
478f70a0e6
|
@ -0,0 +1,10 @@
|
||||||
|
export const decode = base64 => {
|
||||||
|
const rawData = window.atob(base64);
|
||||||
|
const outputArray = new Uint8Array(rawData.length);
|
||||||
|
|
||||||
|
for (let i = 0; i < rawData.length; ++i) {
|
||||||
|
outputArray[i] = rawData.charCodeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputArray;
|
||||||
|
};
|
|
@ -3,7 +3,9 @@ import 'intl/locale-data/jsonp/en';
|
||||||
import 'es6-symbol/implement';
|
import 'es6-symbol/implement';
|
||||||
import includes from 'array-includes';
|
import includes from 'array-includes';
|
||||||
import assign from 'object-assign';
|
import assign from 'object-assign';
|
||||||
|
import values from 'object.values';
|
||||||
import isNaN from 'is-nan';
|
import isNaN from 'is-nan';
|
||||||
|
import { decode as decodeBase64 } from './base64';
|
||||||
|
|
||||||
if (!Array.prototype.includes) {
|
if (!Array.prototype.includes) {
|
||||||
includes.shim();
|
includes.shim();
|
||||||
|
@ -13,6 +15,30 @@ if (!Object.assign) {
|
||||||
Object.assign = assign;
|
Object.assign = assign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Object.values) {
|
||||||
|
values.shim();
|
||||||
|
}
|
||||||
|
|
||||||
if (!Number.isNaN) {
|
if (!Number.isNaN) {
|
||||||
Number.isNaN = isNaN;
|
Number.isNaN = isNaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!HTMLCanvasElement.prototype.toBlob) {
|
||||||
|
const BASE64_MARKER = ';base64,';
|
||||||
|
|
||||||
|
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
|
||||||
|
value(callback, type = 'image/png', quality) {
|
||||||
|
const dataURL = this.toDataURL(type, quality);
|
||||||
|
let data;
|
||||||
|
|
||||||
|
if (dataURL.indexOf(BASE64_MARKER) >= 0) {
|
||||||
|
const [, base64] = dataURL.split(BASE64_MARKER);
|
||||||
|
data = decodeBase64(base64);
|
||||||
|
} else {
|
||||||
|
[, data] = dataURL.split(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(new Blob([data], { type }));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -12,11 +12,13 @@ function importExtraPolyfills() {
|
||||||
|
|
||||||
function loadPolyfills() {
|
function loadPolyfills() {
|
||||||
const needsBasePolyfills = !(
|
const needsBasePolyfills = !(
|
||||||
|
Array.prototype.includes &&
|
||||||
|
HTMLCanvasElement.prototype.toBlob &&
|
||||||
window.Intl &&
|
window.Intl &&
|
||||||
Object.assign &&
|
|
||||||
Number.isNaN &&
|
Number.isNaN &&
|
||||||
window.Symbol &&
|
Object.assign &&
|
||||||
Array.prototype.includes
|
Object.values &&
|
||||||
|
window.Symbol
|
||||||
);
|
);
|
||||||
|
|
||||||
// Latest version of Firefox and Safari do not have IntersectionObserver.
|
// Latest version of Firefox and Safari do not have IntersectionObserver.
|
||||||
|
|
Loading…
Reference in New Issue