diff --git a/lib/events.js b/lib/events.js index 4cfa740765..dd4fdf64e7 100644 --- a/lib/events.js +++ b/lib/events.js @@ -73,6 +73,9 @@ EventEmitter.prototype.emit = function(type) { } } + if (!this._events) + this._events = {}; + handler = this._events[type]; if (typeof handler === 'undefined') diff --git a/test/simple/test-event-emitter-subclass.js b/test/simple/test-event-emitter-subclass.js index a71a7c73c4..537b682088 100644 --- a/test/simple/test-event-emitter-subclass.js +++ b/test/simple/test-event-emitter-subclass.js @@ -27,6 +27,7 @@ var util = require('util'); util.inherits(MyEE, EventEmitter); function MyEE(cb) { + this.emit('bar'); this.on('foo', cb); process.nextTick(this.emit.bind(this, 'foo')); EventEmitter.call(this);