FIX: Add `String.includes` polyfill for IE11

This commit is contained in:
David Taylor 2018-10-26 23:10:03 +01:00
parent cd9a41be55
commit 375bba3c31
1 changed files with 17 additions and 0 deletions

View File

@ -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 */ /* eslint-enable */