Skip to content

Commit

Permalink
fix non-enumerable integer keys issue in Nashorn ~ JDK8 bug, close #389
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Apr 9, 2018
1 parent 142bc57 commit b6c7bb8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 11 additions & 1 deletion packages/core-js/internals/object-property-is-enumerable.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
exports.f = {}.propertyIsEnumerable;
'use strict';
var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;

// Nashorn ~ JDK8 bug
var NASHORN_BUG = nativeGetOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);

exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
var descriptor = nativeGetOwnPropertyDescriptor(this, V);
return !!descriptor && descriptor.enumerable;
} : nativePropertyIsEnumerable;
7 changes: 4 additions & 3 deletions packages/core-js/modules/es.symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var nativeObjectCreate = require('../internals/object-create');
var getOwnPropertyNamesExternal = require('../internals/object-get-own-property-names-external');
var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
var definePropertyModule = require('../internals/object-define-property');
var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
var hide = require('../internals/hide');
var objectKeys = require('../internals/object-keys');
var HIDDEN = require('../internals/shared-key')('hidden');
Expand All @@ -39,7 +40,7 @@ var JSON = global.JSON;
var nativeJSONStringify = JSON && JSON.stringify;
var PROTOTYPE = 'prototype';
var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
var SymbolRegistry = shared('symbol-registry');
var AllSymbols = shared('symbols');
var ObjectPrototypeSymbols = shared('op-symbols');
Expand Down Expand Up @@ -165,10 +166,10 @@ if (!USE_NATIVE) {
return getInternalState(this).tag;
});

getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
propertyIsEnumerableModule.f = $propertyIsEnumerable;
definePropertyModule.f = $defineProperty;
getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
require('../internals/object-get-own-property-names').f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
require('../internals/object-property-is-enumerable').f = $propertyIsEnumerable;
require('../internals/object-get-own-property-symbols').f = $getOwnPropertySymbols;

if (DESCRIPTORS) {
Expand Down

0 comments on commit b6c7bb8

Please sign in to comment.