mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Always return emitter from #on()
This commit is contained in:
parent
19a9976939
commit
d5471c480f
1 changed files with 12 additions and 12 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue