FIX: Add `String.includes` polyfill for IE11
This commit is contained in:
parent
cd9a41be55
commit
375bba3c31
|
@ -94,4 +94,21 @@ if (!Array.prototype.includes) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill
|
||||
if (!String.prototype.includes) {
|
||||
Object.defineProperty(String.prototype, 'includes', {
|
||||
value: function(search, start) {
|
||||
if (typeof start !== 'number') {
|
||||
start = 0
|
||||
}
|
||||
|
||||
if (start + search.length > this.length) {
|
||||
return false
|
||||
} else {
|
||||
return this.indexOf(search, start) !== -1
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
/* eslint-enable */
|
||||
|
|
Loading…
Reference in New Issue