Adding an robustness test before using the registered events member.
authormanufitoussi <manu.fitoussi@gmail.com>
Fri, 25 Jan 2013 13:25:46 +0000 (14:25 +0100)
committermanufitoussi <manu.fitoussi@gmail.com>
Fri, 25 Jan 2013 13:25:46 +0000 (14:25 +0100)
dygraph.js

index ae089d0..fc50740 100644 (file)
@@ -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)