From 9719c770d3953c55485e91a2a383a918ab10021a Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Sun, 17 Nov 2013 17:58:21 +1000 Subject: [PATCH] Use Object.create for inheritance --- lib/ace/lib/oop.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/ace/lib/oop.js b/lib/ace/lib/oop.js index f3dbb1d9..104e8290 100644 --- a/lib/ace/lib/oop.js +++ b/lib/ace/lib/oop.js @@ -32,12 +32,25 @@ define(function(require, exports, module) { "use strict"; exports.inherits = (function() { - var tempCtor = function() {}; + var createObject = Object.create || function(prototype, properties) { + var Type = function () {}; + Type.prototype = prototype; + object = new Type(); + object.__proto__ = prototype; + if (typeof properties !== 'undefined' && Object.defineProperties) { + Object.defineProperties(object, properties); + } + }; return function(ctor, superCtor) { - tempCtor.prototype = superCtor.prototype; - ctor.super_ = superCtor.prototype; - ctor.prototype = new tempCtor(); - ctor.prototype.constructor = ctor; + ctor.super_ = superCtor; + ctor.prototype = createObject(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); }; }());