From: manufitoussi Date: Fri, 25 Jan 2013 13:25:46 +0000 (+0100) Subject: Adding an robustness test before using the registered events member. X-Git-Tag: v1.0.0~105^2~10 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=f82e5caf5d53d50b533f82cc65bd6583cd3a1fd9;p=dygraphs.git Adding an robustness test before using the registered events member. --- diff --git a/dygraph.js b/dygraph.js index ae089d0..fc50740 100644 --- a/dygraph.js +++ b/dygraph.js @@ -994,10 +994,13 @@ Dygraph.prototype.destroy = function() { } }; - for (var idx = 0; idx < this.registeredEvents_.length; idx++) { - var reg = this.registeredEvents_[idx]; - Dygraph.removeEvent(reg.elem, reg.type, reg.fn); + if (this.registeredEvents_) { + for (var idx = 0; idx < this.registeredEvents_.length; idx++) { + var reg = this.registeredEvents_[idx]; + Dygraph.removeEvent(reg.elem, reg.type, reg.fn); + } } + this.registeredEvents_ = []; // remove mouse event handlers (This may not be necessary anymore)