[Commits] r2548 - in core/trunk/geoext: lib/GeoExt/plugins tests/lib/GeoExt/plugins

commits at geoext.org commits at geoext.org
Mon Jan 10 12:32:22 CET 2011


Author: fredj
Date: 2011-01-10 12:32:21 +0100 (Mon, 10 Jan 2011)
New Revision: 2548

Modified:
   core/trunk/geoext/lib/GeoExt/plugins/TreeNodeComponent.js
   core/trunk/geoext/tests/lib/GeoExt/plugins/TreeNodeComponent.html
Log:
Perform destroy action in an onBeforeDestroy listener. r=elemoine (closes #390)

Modified: core/trunk/geoext/lib/GeoExt/plugins/TreeNodeComponent.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/plugins/TreeNodeComponent.js	2011-01-07 23:54:01 UTC (rev 2547)
+++ core/trunk/geoext/lib/GeoExt/plugins/TreeNodeComponent.js	2011-01-10 11:32:21 UTC (rev 2548)
@@ -84,6 +84,7 @@
     init: function(tree) {
         tree.on({
             "rendernode": this.onRenderNode,
+            "beforedestroy": this.onBeforeDestroy,
             scope: this
         });
     },
@@ -118,10 +119,11 @@
         }
     },
     
-    /** private: method[destroy]
+    /** private: method[onBeforeDestroy]
      */
-    destroy: function() {
+    onBeforeDestroy: function(tree) {
         tree.un("rendernode", this.onRenderNode, this);
+        tree.un("beforedestroy", this.onBeforeDestroy, this);
     }
 
 });

Modified: core/trunk/geoext/tests/lib/GeoExt/plugins/TreeNodeComponent.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/plugins/TreeNodeComponent.html	2011-01-07 23:54:01 UTC (rev 2547)
+++ core/trunk/geoext/tests/lib/GeoExt/plugins/TreeNodeComponent.html	2011-01-10 11:32:21 UTC (rev 2548)
@@ -213,6 +213,34 @@
 
             // teardown
         }
+
+        function test_destroy(t) {
+            t.plan(2);
+            var component, node, tree;
+
+            component = new Ext.Panel({
+                id: "foo-id",
+                cls: "foo-cls",
+                ctCls: "foo-ct-cls"
+            });
+            node = new GeoExt.tree.LayerNode({
+                uiProvider: UI,
+                layer: new OpenLayers.Layer(),
+                component: component
+            });
+            tree = new Ext.tree.TreePanel({
+                renderTo: "tree",
+                root: node,
+                plugins: [new GeoExt.plugins.TreeNodeComponent()]
+            });
+
+            t.ok(tree.hasListener("rendernode"), 
+                 "plugin listen the 'rendernode' event from the tree");
+            tree.destroy();
+            t.ok(!tree.hasListener("rendernode"), 
+                 "destroy unbinds plugin from tree");
+        }
+
          </script>
     </head>
     <body>



More information about the Commits mailing list