From 6b428f5a37e32bff25b62261fb279f77daab542d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Wed, 13 May 2015 20:21:22 +0200 Subject: [PATCH] Assume that Emiter#_evenTypes is not always defined. Resolves https://github.com/paperjs/paper.js/pull/674#discussion_r30042363 --- src/core/Emitter.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/Emitter.js b/src/core/Emitter.js index 55e1442e..d9b571da 100644 --- a/src/core/Emitter.js +++ b/src/core/Emitter.js @@ -23,7 +23,8 @@ var Emitter = { this.on(key, value); }, this); } else { - var entry = this._eventTypes[type], + var types = this._eventTypes, + entry = types && types[type], handlers = this._callbacks = this._callbacks || {}; handlers = handlers[type] = handlers[type] || []; if (handlers.indexOf(func) === -1) { // Not added yet, add now. @@ -45,7 +46,8 @@ var Emitter = { }, this); return; } - var entry = this._eventTypes[type], + var types = this._eventTypes, + entry = types && types[type], handlers = this._callbacks && this._callbacks[type], index; if (handlers) { @@ -103,7 +105,8 @@ var Emitter = { key = install ? 'install' : 'uninstall'; for (var type in handlers) { if (handlers[type].length > 0) { - var entry = this._eventTypes[type], + var types = this._eventTypes, + entry = types && types[type], func = entry && entry[key]; if (func) func.call(this, type);