fix ie8 object.create
This commit is contained in:
parent
f38a4e0e5b
commit
e0727f8b31
1 changed files with 24 additions and 1 deletions
|
|
@ -543,10 +543,33 @@ if (!Object.getOwnPropertyNames) {
|
|||
// ES5 15.2.3.5
|
||||
// http://es5.github.com/#x15.2.3.5
|
||||
if (!Object.create) {
|
||||
var createEmpty;
|
||||
if (Object.prototype.__proto__ === null) {
|
||||
createEmpty = function () {
|
||||
return { "__proto__": null };
|
||||
};
|
||||
} else {
|
||||
// In old IE __proto__ can't be used to manually set `null`
|
||||
createEmpty = function () {
|
||||
var empty = {};
|
||||
for (var i in empty)
|
||||
empty[i] = null;
|
||||
empty.constructor =
|
||||
empty.hasOwnProperty =
|
||||
empty.propertyIsEnumerable =
|
||||
empty.isPrototypeOf =
|
||||
empty.toLocaleString =
|
||||
empty.toString =
|
||||
empty.valueOf =
|
||||
empty.__proto__ = null;
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
Object.create = function create(prototype, properties) {
|
||||
var object;
|
||||
if (prototype === null) {
|
||||
object = { "__proto__": null };
|
||||
object = createEmpty();
|
||||
} else {
|
||||
if (typeof prototype != "object")
|
||||
throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue