a start with polyfill

This commit is contained in:
Matteo Manzinello 2020-07-15 12:10:40 +02:00
parent 72ad465134
commit 9c8f9283b3
7 changed files with 53 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/mailgo.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,6 @@
// webpack > dist/mailgo.min.js
import mailgoPolyfill from "./polyfill";
import mailgo from "../src/mailgo";
// call init mailgo attached to the event DOMContentLoaded
@ -8,4 +9,6 @@ const mailgoConfig = {
dark: true,
};
mailgoPolyfill();
mailgo(mailgoConfig);

View File

@ -1,5 +1,6 @@
// webpack > dist/mailgo.min.js
import mailgoPolyfill from "./polyfill";
import mailgo from "../src/mailgo";
// call init mailgo attached to the event DOMContentLoaded
@ -7,4 +8,6 @@ const mailgoConfig = {
initEvent: "DOMContentLoaded",
};
mailgoPolyfill();
mailgo(mailgoConfig);

43
webpack/polyfill.js Normal file
View File

@ -0,0 +1,43 @@
// polyfill for mailgo
export default mailgoPolyfill = () => {
if (!Array.prototype.includes) {
Array.prototype.includes = function (searchElement /*, fromIndex*/) {
"use strict";
if (this == null) {
throw new TypeError(
"Array.prototype.includes called on null or undefined"
);
}
var O = Object(this);
var len = parseInt(O.length, 10) || 0;
if (len === 0) {
return false;
}
var n = parseInt(arguments[1], 10) || 0;
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) {
k = 0;
}
}
var currentElement;
while (k < len) {
currentElement = O[k];
if (
searchElement === currentElement ||
(searchElement !== searchElement && currentElement !== currentElement)
) {
// NaN !== NaN
return true;
}
k++;
}
return false;
};
}
};