From 275bb6ffacd78f538b672ea3208d3104df1f11a2 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Mon, 11 Nov 2013 22:05:50 -0800 Subject: [PATCH] Stop overwriting the static methods --- lib/model-builder.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/model-builder.js b/lib/model-builder.js index 9ab831ad..07d7c838 100644 --- a/lib/model-builder.js +++ b/lib/model-builder.js @@ -154,7 +154,7 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett var events = new EventEmitter(); for (var f in EventEmitter.prototype) { if (typeof EventEmitter.prototype[f] === 'function') { - ModelClass[f] = events[f].bind(events); + ModelClass[f] = EventEmitter.prototype[f].bind(events); } } util.inherits(ModelClass, ModelBaseClass); @@ -178,9 +178,10 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett // inherit ModelBaseClass static methods for (var i in ModelBaseClass) { - if(i !== '_mixins') { - ModelClass[i] = ModelBaseClass[i]; - } + // We need to skip properties that are already in the subclass, for example, the event emitter methods + if(i !== '_mixins' && !(i in ModelClass)) { + ModelClass[i] = ModelBaseClass[i]; + } } ModelClass.getter = {};