.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / object-create.js
1 var anObject = require('../internals/an-object');
2 var defineProperties = require('../internals/object-define-properties');
3 var enumBugKeys = require('../internals/enum-bug-keys');
4 var hiddenKeys = require('../internals/hidden-keys');
5 var html = require('../internals/html');
6 var documentCreateElement = require('../internals/document-create-element');
7 var sharedKey = require('../internals/shared-key');
8
9 var GT = '>';
10 var LT = '<';
11 var PROTOTYPE = 'prototype';
12 var SCRIPT = 'script';
13 var IE_PROTO = sharedKey('IE_PROTO');
14
15 var EmptyConstructor = function () { /* empty */ };
16
17 var scriptTag = function (content) {
18   return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
19 };
20
21 // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
22 var NullProtoObjectViaActiveX = function (activeXDocument) {
23   activeXDocument.write(scriptTag(''));
24   activeXDocument.close();
25   var temp = activeXDocument.parentWindow.Object;
26   activeXDocument = null; // avoid memory leak
27   return temp;
28 };
29
30 // Create object with fake `null` prototype: use iframe Object with cleared prototype
31 var NullProtoObjectViaIFrame = function () {
32   // Thrash, waste and sodomy: IE GC bug
33   var iframe = documentCreateElement('iframe');
34   var JS = 'java' + SCRIPT + ':';
35   var iframeDocument;
36   iframe.style.display = 'none';
37   html.appendChild(iframe);
38   // https://github.com/zloirock/core-js/issues/475
39   iframe.src = String(JS);
40   iframeDocument = iframe.contentWindow.document;
41   iframeDocument.open();
42   iframeDocument.write(scriptTag('document.F=Object'));
43   iframeDocument.close();
44   return iframeDocument.F;
45 };
46
47 // Check for document.domain and active x support
48 // No need to use active x approach when document.domain is not set
49 // see https://github.com/es-shims/es5-shim/issues/150
50 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
51 // avoid IE GC bug
52 var activeXDocument;
53 var NullProtoObject = function () {
54   try {
55     /* global ActiveXObject -- old IE */
56     activeXDocument = document.domain && new ActiveXObject('htmlfile');
57   } catch (error) { /* ignore */ }
58   NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
59   var length = enumBugKeys.length;
60   while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
61   return NullProtoObject();
62 };
63
64 hiddenKeys[IE_PROTO] = true;
65
66 // `Object.create` method
67 // https://tc39.es/ecma262/#sec-object.create
68 module.exports = Object.create || function create(O, Properties) {
69   var result;
70   if (O !== null) {
71     EmptyConstructor[PROTOTYPE] = anObject(O);
72     result = new EmptyConstructor();
73     EmptyConstructor[PROTOTYPE] = null;
74     // add "__proto__" for Object.getPrototypeOf polyfill
75     result[IE_PROTO] = O;
76   } else result = NullProtoObject();
77   return Properties === undefined ? result : defineProperties(result, Properties);
78 };