diff --git a/lib/pilot/event_emitter.js b/lib/pilot/event_emitter.js index 5203681..76bfd7b 100644 --- a/lib/pilot/event_emitter.js +++ b/lib/pilot/event_emitter.js @@ -43,27 +43,34 @@ var EventEmitter = {}; EventEmitter._emit = EventEmitter._dispatchEvent = function(eventName, e) { - this._eventRegistry = this._eventRegistry || {}; + if (!this.hasOwnProperty('_eventRegistry')) { + return; + } var listeners = this._eventRegistry[eventName]; - if (!listeners || !listeners.length) return; + if (!listeners || !listeners.length) { + return; + } var e = e || {}; e.type = eventName; - for (var i=0; i