]> git.r.bdr.sh - rbdr/dotfiles/blob
f813b4661c4498f434925cc883ebaa8af97e3d77
[rbdr/dotfiles] /
1 // Workaround for http://code.google.com/p/v8/issues/detail?id=2804
2
3 'use strict';
4
5 var create = Object.create, shim;
6
7 if (!require('./set-prototype-of/is-implemented')()) {
8 shim = require('./set-prototype-of/shim');
9 }
10
11 module.exports = (function () {
12 var nullObject, props, desc;
13 if (!shim) return create;
14 if (shim.level !== 1) return create;
15
16 nullObject = {};
17 props = {};
18 desc = { configurable: false, enumerable: false, writable: true,
19 value: undefined };
20 Object.getOwnPropertyNames(Object.prototype).forEach(function (name) {
21 if (name === '__proto__') {
22 props[name] = { configurable: true, enumerable: false, writable: true,
23 value: undefined };
24 return;
25 }
26 props[name] = desc;
27 });
28 Object.defineProperties(nullObject, props);
29
30 Object.defineProperty(shim, 'nullPolyfill', { configurable: false,
31 enumerable: false, writable: false, value: nullObject });
32
33 return function (prototype, props) {
34 return create((prototype === null) ? nullObject : prototype, props);
35 };
36 }());