From 3771519de0bd2581afe862d2db8cf2a4517248a7 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Tue, 10 Aug 2021 18:46:19 +0700 Subject: [PATCH] fix #970 --- CHANGELOG.md | 2 +- packages/core-js/internals/object-create.js | 29 ++++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d07d18d4b2f..8d3079031abc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## Changelog ##### Unreleased -- Nothing +- One more fix crashing of `Object.create(null)` on WSH, [#970](https://github.com/zloirock/core-js/issues/970) ##### 3.16.1 - 2021.08.09 - Fixed microtask implementation on iOS Pebble, [#967](https://github.com/zloirock/core-js/issues/967) diff --git a/packages/core-js/internals/object-create.js b/packages/core-js/internals/object-create.js index fff3ac66d270..24a27a65d879 100644 --- a/packages/core-js/internals/object-create.js +++ b/packages/core-js/internals/object-create.js @@ -34,17 +34,15 @@ var NullProtoObjectViaIFrame = function () { var iframe = documentCreateElement('iframe'); var JS = 'java' + SCRIPT + ':'; var iframeDocument; - if (iframe.style) { - iframe.style.display = 'none'; - html.appendChild(iframe); - // https://github.com/zloirock/core-js/issues/475 - iframe.src = String(JS); - iframeDocument = iframe.contentWindow.document; - iframeDocument.open(); - iframeDocument.write(scriptTag('document.F=Object')); - iframeDocument.close(); - return iframeDocument.F; - } + iframe.style.display = 'none'; + html.appendChild(iframe); + // https://github.com/zloirock/core-js/issues/475 + iframe.src = String(JS); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(scriptTag('document.F=Object')); + iframeDocument.close(); + return iframeDocument.F; }; // Check for document.domain and active x support @@ -57,10 +55,11 @@ var NullProtoObject = function () { try { activeXDocument = new ActiveXObject('htmlfile'); } catch (error) { /* ignore */ } - NullProtoObject = document.domain && activeXDocument ? - NullProtoObjectViaActiveX(activeXDocument) : // old IE - NullProtoObjectViaIFrame() || - NullProtoObjectViaActiveX(activeXDocument); // WSH + NullProtoObject = typeof document != 'undefined' + ? document.domain && activeXDocument + ? NullProtoObjectViaActiveX(activeXDocument) // old IE + : NullProtoObjectViaIFrame() + : NullProtoObjectViaActiveX(activeXDocument); // WSH var length = enumBugKeys.length; while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; return NullProtoObject();