Skip to content

Commit

Permalink
make it as a singleton pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
aleen42 committed Dec 14, 2019
1 parent cce6aa5 commit e0ee57d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/core-js/internals/object-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ var EmptyConstructor = function () { /* empty */ };
var NullProtoObject = function (ProtoObject) {
var length = enumBugKeys.length;
while (length--) delete ProtoObject[PROTOTYPE][enumBugKeys[length]];
return ProtoObject();
return ProtoObject;
};

// Create object with fake `null` prototype: use ActiveX Object with cleared prototype
var NullProtoObjectViaActiveX = function () {
var NullProtoObjectViaActiveX = (function () {
// Check for document.domain and active x support
// No need to use active x approach when document.domain is not set
// see https://github.com/es-shims/es5-shim/issues/150
Expand All @@ -33,10 +33,10 @@ var NullProtoObjectViaActiveX = function () {
var ProtoObject = activeXDocument.parentWindow.Object;
activeXDocument = null;
return NullProtoObject(ProtoObject)
};
})();

// Create object with fake `null` prototype: use iframe Object with cleared prototype
var NullProtoObjectViaIFrame = function () {
var NullProtoObjectViaIFrame = (function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = documentCreateElement('iframe');
var GT = '>';
Expand All @@ -53,7 +53,7 @@ var NullProtoObjectViaIFrame = function () {
iframeDocument.write(LT + SCRIPT + GT + 'document.F=Object' + LT + '/' + SCRIPT + GT);
iframeDocument.close();
return NullProtoObject(iframeDocument.F);
};
})();

hiddenKeys[IE_PROTO] = true;

Expand All @@ -67,6 +67,6 @@ module.exports = Object.create || function create(O, Properties) {
EmptyConstructor[PROTOTYPE] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = NullProtoObjectViaActiveX() || NullProtoObjectViaIFrame();
} else result = NullProtoObjectViaActiveX ? NullProtoObjectViaActiveX() : NullProtoObjectViaIFrame();
return Properties === undefined ? result : defineProperties(result, Properties);
};

0 comments on commit e0ee57d

Please sign in to comment.