From e0727f8b315c8b6ffbaa2c2a47ffa11274b4e29e Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 26 Oct 2012 15:11:52 +0400 Subject: [PATCH] fix ie8 object.create --- lib/ace/lib/es5-shim.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/ace/lib/es5-shim.js b/lib/ace/lib/es5-shim.js index c0e7999c..3a3b68c5 100644 --- a/lib/ace/lib/es5-shim.js +++ b/lib/ace/lib/es5-shim.js @@ -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'");