Skip to content

Commit

Permalink
Create an empty object without prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
kellym committed Aug 18, 2021
1 parent 9cd8119 commit ef571d6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core-js-pure/override/internals/export.js
Expand Up @@ -21,6 +21,10 @@ var wrapConstructor = function (NativeConstructor) {
return Wrapper;
};

var createEmptyObject = function () {
return Object.create ? Object.create(null) : {};
};

/*
options.target - name of the target object
options.global - target is the global object
Expand All @@ -43,7 +47,7 @@ module.exports = function (options, source) {

var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype;

var target = GLOBAL ? path : path[TARGET] || (path[TARGET] = {});
var target = GLOBAL ? path : path[TARGET] || (path[TARGET] = createEmptyObject());
var targetPrototype = target.prototype;

var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
Expand Down Expand Up @@ -85,7 +89,7 @@ module.exports = function (options, source) {
if (PROTO) {
VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
if (!has(path, VIRTUAL_PROTOTYPE)) {
createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, createEmptyObject());
}
// export virtual prototype methods
path[VIRTUAL_PROTOTYPE][key] = sourceProperty;
Expand Down

0 comments on commit ef571d6

Please sign in to comment.