mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Assume that Emiter#_evenTypes is not always defined.
Resolves https://github.com/paperjs/paper.js/pull/674#discussion_r30042363
This commit is contained in:
parent
75c6db6986
commit
6b428f5a37
1 changed files with 6 additions and 3 deletions
|
@ -23,7 +23,8 @@ var Emitter = {
|
||||||
this.on(key, value);
|
this.on(key, value);
|
||||||
}, this);
|
}, this);
|
||||||
} else {
|
} else {
|
||||||
var entry = this._eventTypes[type],
|
var types = this._eventTypes,
|
||||||
|
entry = types && types[type],
|
||||||
handlers = this._callbacks = this._callbacks || {};
|
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 now.
|
||||||
|
@ -45,7 +46,8 @@ var Emitter = {
|
||||||
}, this);
|
}, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var entry = this._eventTypes[type],
|
var types = this._eventTypes,
|
||||||
|
entry = types && types[type],
|
||||||
handlers = this._callbacks && this._callbacks[type],
|
handlers = this._callbacks && this._callbacks[type],
|
||||||
index;
|
index;
|
||||||
if (handlers) {
|
if (handlers) {
|
||||||
|
@ -103,7 +105,8 @@ var Emitter = {
|
||||||
key = install ? 'install' : 'uninstall';
|
key = install ? 'install' : 'uninstall';
|
||||||
for (var type in handlers) {
|
for (var type in handlers) {
|
||||||
if (handlers[type].length > 0) {
|
if (handlers[type].length > 0) {
|
||||||
var entry = this._eventTypes[type],
|
var types = this._eventTypes,
|
||||||
|
entry = types && types[type],
|
||||||
func = entry && entry[key];
|
func = entry && entry[key];
|
||||||
if (func)
|
if (func)
|
||||||
func.call(this, type);
|
func.call(this, type);
|
||||||
|
|
Loading…
Reference in a new issue