Fix #1027: create IE11 Array polyfills `find` and `findIndex` in such a way that they are not iterable
This commit is contained in:
parent
70a2f94693
commit
b6235a8d23
|
@ -7,6 +7,8 @@ https://github.com/josdejong/jsoneditor
|
|||
|
||||
- Fixed broken link to the Ace editor website (https://ace.c9.io/).
|
||||
Thanks @p3x-robot.
|
||||
- Fix #1027: create IE11 Array polyfills `find` and `findIndex` in such a way
|
||||
that they are not iterable.
|
||||
|
||||
|
||||
## 2020-05-24, version 9.0.0
|
||||
|
|
|
@ -25,7 +25,8 @@ if (typeof Element !== 'undefined') {
|
|||
// simple polyfill for Array.findIndex
|
||||
if (!Array.prototype.findIndex) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.findIndex = function (predicate) {
|
||||
Object.defineProperty(Array.prototype, 'findIndex', {
|
||||
value: function (predicate) {
|
||||
for (let i = 0; i < this.length; i++) {
|
||||
const element = this[i]
|
||||
if (predicate.call(this, element, i, this)) {
|
||||
|
@ -33,16 +34,23 @@ if (!Array.prototype.findIndex) {
|
|||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
},
|
||||
configurable: true,
|
||||
writable: true
|
||||
})
|
||||
}
|
||||
|
||||
// Polyfill for Array.find
|
||||
if (!Array.prototype.find) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.find = function (predicate) {
|
||||
Object.defineProperty(Array.prototype, 'find', {
|
||||
value: function (predicate) {
|
||||
const i = this.findIndex(predicate)
|
||||
return this[i]
|
||||
}
|
||||
},
|
||||
configurable: true,
|
||||
writable: true
|
||||
})
|
||||
}
|
||||
|
||||
// Polyfill for String.trim
|
||||
|
|
Loading…
Reference in New Issue