From: Klaus Weidner Date: Tue, 10 Apr 2012 22:49:46 +0000 (-0700) Subject: Avoid calling length on undefined if no event handlers are registered. X-Git-Tag: v1.0.0~283^2~2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=da1c187b3c86d2b906280c35de7ff9f744d1c000;p=dygraphs.git Avoid calling length on undefined if no event handlers are registered. --- diff --git a/dygraph.js b/dygraph.js index e1cdd4e..1ebe261 100644 --- a/dygraph.js +++ b/dygraph.js @@ -483,11 +483,13 @@ Dygraph.prototype.cascadeEvents_ = function(name, extra_props) { Dygraph.update(e, extra_props); var callback_plugin_pairs = this.eventListeners_[name]; - for (var i = callback_plugin_pairs.length - 1; i >= 0; i--) { - var plugin = callback_plugin_pairs[i][0]; - var callback = callback_plugin_pairs[i][1]; - callback.call(plugin, e); - if (e.propagationStopped) break; + if (callback_plugin_pairs) { + for (var i = callback_plugin_pairs.length - 1; i >= 0; i--) { + var plugin = callback_plugin_pairs[i][0]; + var callback = callback_plugin_pairs[i][1]; + callback.call(plugin, e); + if (e.propagationStopped) break; + } } return e.defaultPrevented; };