|
1 | 1 | var DESCRIPTORS = require('../internals/descriptors'); |
| 2 | +var fails = require('../internals/fails'); |
2 | 3 | var uncurryThis = require('../internals/function-uncurry-this'); |
| 4 | +var objectGetPrototypeOf = require('../internals/object-get-prototype-of'); |
3 | 5 | var objectKeys = require('../internals/object-keys'); |
4 | 6 | var toIndexedObject = require('../internals/to-indexed-object'); |
5 | 7 | var $propertyIsEnumerable = require('../internals/object-property-is-enumerable').f; |
6 | 8 |
|
7 | 9 | var propertyIsEnumerable = uncurryThis($propertyIsEnumerable); |
8 | 10 | var push = uncurryThis([].push); |
9 | 11 |
|
| 12 | +// in some IE versions, `propertyIsEnumerable` returns incorrect result on integer keys |
| 13 | +// of `null` prototype objects |
| 14 | +var IE_BUG = fails(function () { |
| 15 | + // eslint-disable-next-line es/no-object-create -- safe |
| 16 | + var O = Object.create(null); |
| 17 | + O[2] = 2; |
| 18 | + return !propertyIsEnumerable(O, 2); |
| 19 | +}); |
| 20 | + |
10 | 21 | // `Object.{ entries, values }` methods implementation |
11 | 22 | var createMethod = function (TO_ENTRIES) { |
12 | 23 | return function (it) { |
13 | 24 | var O = toIndexedObject(it); |
14 | 25 | var keys = objectKeys(O); |
| 26 | + var IE_WORKAROUND = IE_BUG && objectGetPrototypeOf(O) === null; |
15 | 27 | var length = keys.length; |
16 | 28 | var i = 0; |
17 | 29 | var result = []; |
18 | 30 | var key; |
19 | 31 | while (length > i) { |
20 | 32 | key = keys[i++]; |
21 | | - if (!DESCRIPTORS || propertyIsEnumerable(O, key)) { |
| 33 | + if (!DESCRIPTORS || (IE_WORKAROUND ? key in O : propertyIsEnumerable(O, key))) { |
22 | 34 | push(result, TO_ENTRIES ? [key, O[key]] : O[key]); |
23 | 35 | } |
24 | 36 | } |
|
0 commit comments