Always return emitter from #on()

This commit is contained in:
Jürg Lehni 2014-11-18 15:05:14 -08:00
parent 19a9976939
commit d5471c480f

View file

@ -22,18 +22,18 @@ var Emitter = {
Base.each(type, function(value, key) { Base.each(type, function(value, key) {
this.on(key, value); this.on(key, value);
}, this); }, this);
return; } else {
} var entry = this._eventTypes[type];
var entry = this._eventTypes[type]; if (entry) {
if (entry) { var handlers = this._callbacks = this._callbacks || {};
var handlers = this._callbacks = this._callbacks || {}; handlers = handlers[type] = handlers[type] || [];
handlers = handlers[type] = handlers[type] || []; if (handlers.indexOf(func) === -1) { // Not added yet, add now.
if (handlers.indexOf(func) === -1) { // Not added yet, add it now handlers.push(func);
handlers.push(func); // See if this is the first handler that we're attaching,
// See if this is the first handler that we're attaching, and // and call install if defined.
// call install if defined. if (entry.install && handlers.length == 1)
if (entry.install && handlers.length == 1) entry.install.call(this, type);
entry.install.call(this, type); }
} }
} }
return this; return this;