a start with polyfill
This commit is contained in:
parent
72ad465134
commit
9c8f9283b3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue