Add polyfill for String.prototype.includes
This commit is contained in:
15
static/scripts/custom/polyfills.js
Normal file
15
static/scripts/custom/polyfills.js
Normal file
@ -0,0 +1,15 @@
|
||||
// Polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
|
||||
if (!String.prototype.includes) {
|
||||
String.prototype.includes = function(search, start) {
|
||||
'use strict';
|
||||
if (typeof start !== 'number') {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
if (start + search.length > this.length) {
|
||||
return false;
|
||||
} else {
|
||||
return this.indexOf(search, start) !== -1;
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user