-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (24 loc) · 939 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// IE9-11 Object.create bug fix
// webreflection.blogspot.com/2014/04/all-ie-objects-are-broken.html
Object.create && function () {
var object = Object.create({});
object[0] = null;
return object.hasOwnProperty(0); //→ false in IE9-11
}() || Object.defineProperty(Object, 'create', function () {
var ObjectCreate = Object.create;
var descriptor = Object.getOwnPropertyDescriptor(Object, 'create');
descriptor.value = function create(prototype, properties) {
var object = ObjectCreate(prototype, properties);
if (!Object.prototype.hasOwnProperty.call(object, 0)) {
// a numeric key fixes the bug,
// it can be removed after,
// unlike the alphabetic key
Object.defineProperty(object, 0, {
configurable: true
});
delete object[0];
}
return object;
};
return descriptor;
}());