Created
April 25, 2015 18:38
-
-
Save nickhs/91661a57f390222d44f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function uid(key){ | |
return 'Symbol(' + key + ')_' + (++sid + Math.random()).toString(36); | |
} | |
uid.safe = require('./$').g.Symbol || uid; | |
module.exports = uid; | |
},{"./$":33}],43:[function(require,module,exports){ | |
// 22.1.3.31 Array.prototype[@@unscopables] | |
var $ = require('./$') | |
, UNSCOPABLES = require('./$.wks')('unscopables'); | |
if($.FW && !(UNSCOPABLES in []))$.hide(Array.prototype, UNSCOPABLES, {}); | |
module.exports = function(key){ | |
if($.FW)[][UNSCOPABLES][key] = true; | |
}; | |
},{"./$":33,"./$.wks":44}],44:[function(require,module,exports){ | |
var global = require('./$').g | |
, store = {}; | |
module.exports = function(name){ | |
return store[name] || (store[name] = | |
global.Symbol && global.Symbol[name] || require('./$.uid').safe('Symbol.' + name)); | |
}; | |
},{"./$":33,"./$.uid":42}],45:[function(require,module,exports){ | |
var $ = require('./$') | |
, cof = require('./$.cof') | |
, $def = require('./$.def') | |
, invoke = require('./$.invoke') | |
, arrayMethod = require('./$.array-methods') | |
, IE_PROTO = require('./$.uid').safe('__proto__') | |
, assert = require('./$.assert') | |
, assertObject = assert.obj | |
, ObjectProto = Object.prototype | |
, A = [] | |
, slice = A.slice | |
, indexOf = A.indexOf | |
, classof = cof.classof | |
, has = $.has | |
, defineProperty = $.setDesc | |
, getOwnDescriptor = $.getDesc | |
, defineProperties = $.setDescs | |
, isFunction = $.isFunction | |
, toObject = $.toObject | |
, toLength = $.toLength | |
, IE8_DOM_DEFINE = false; | |
if(!$.DESC){ | |
try { | |
IE8_DOM_DEFINE = defineProperty(document.createElement('div'), 'x', | |
{get: function(){ return 8; }} | |
).x == 8; | |
} catch(e){ /* empty */ } | |
$.setDesc = function(O, P, Attributes){ | |
if(IE8_DOM_DEFINE)try { | |
return defineProperty(O, P, Attributes); | |
} catch(e){ /* empty */ } | |
if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); | |
if('value' in Attributes)assertObject(O)[P] = Attributes.value; | |
return O; | |
}; | |
$.getDesc = function(O, P){ | |
if(IE8_DOM_DEFINE)try { | |
return getOwnDescriptor(O, P); | |
} catch(e){ /* empty */ } | |
if(has(O, P))return $.desc(!ObjectProto.propertyIsEnumerable.call(O, P), O[P]); | |
}; | |
$.setDescs = defineProperties = function(O, Properties){ | |
assertObject(O); | |
var keys = $.getKeys(Properties) | |
, length = keys.length | |
, i = 0 | |
, P; | |
while(length > i)$.setDesc(O, P = keys[i++], Properties[P]); | |
return O; | |
}; | |
} | |
$def($def.S + $def.F * !$.DESC, 'Object', { | |
// 19.1.2.6 / 15.2.3.3 Object.getOwnPropertyDescriptor(O, P) | |
getOwnPropertyDescriptor: $.getDesc, | |
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) | |
defineProperty: $.setDesc, | |
// 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) | |
defineProperties: defineProperties | |
}); | |
// IE 8- don't enum bug keys | |
var keys1 = ('constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,' + | |
'toLocaleString,toString,valueOf').split(',') | |
// Additional keys for getOwnPropertyNames | |
, keys2 = keys1.concat('length', 'prototype') | |
, keysLen1 = keys1.length; | |
// Create object with `null` prototype: use iframe Object with cleared prototype | |
var createDict = function(){ | |
// Thrash, waste and sodomy: IE GC bug | |
var iframe = document.createElement('iframe') | |
, i = keysLen1 | |
, gt = '>' | |
, iframeDocument; | |
iframe.style.display = 'none'; | |
$.html.appendChild(iframe); | |
iframe.src = 'javascript:'; // eslint-disable-line no-script-url | |
// createDict = iframe.contentWindow.Object; | |
// html.removeChild(iframe); | |
iframeDocument = iframe.contentWindow.document; | |
iframeDocument.open(); | |
iframeDocument.write('<script>document.F=Object</script' + gt); | |
iframeDocument.close(); | |
createDict = iframeDocument.F; | |
while(i--)delete createDict.prototype[keys1[i]]; | |
return createDict(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment