LP#1086458: clean up event listener functions
authorGalen Charlton <gmc@esilibrary.com>
Wed, 30 Jan 2013 15:59:10 +0000 (10:59 -0500)
committerBen Shum <bshum@biblio.org>
Mon, 4 Mar 2013 19:49:33 +0000 (14:49 -0500)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/xul/staff_client/chrome/content/OpenILS/event_util.js

index 39934b4..6e7d09d 100644 (file)
@@ -21,13 +21,16 @@ EventListenerList.prototype = {
     'removeAll' : function() {
         try {
             if (typeof this._listeners != 'undefined') {
-                for (var i = 0; i < this._listeners.length; i++) {
+                for (var i = this._listeners.length - 1; i >= 0; i--) {
                     this._listeners[i].node.removeEventListener(
                         this._listeners[i].type,
                         this._listeners[i].listener,
                         this._listeners[i].useCapture
                     );
+                    this._listeners[i].listener = null;
+                    delete this._listeners[i];
                 }
+                this._listeners = [];
             }
         } catch(E) {
             alert(location.href + ' Error in unloadEventListeners(): ' + E);