From e1a32ba630a72907195859b98e0ccc278207dfd3 Mon Sep 17 00:00:00 2001 From: bartvde Date: Mon, 7 Mar 2011 05:02:51 +0000 Subject: [PATCH] Control should set this.div to null in destroy, thanks jorix for the updated patch, p=jorix,me r=me,fredj (closes #2850) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11631 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control.js | 1 + lib/OpenLayers/Control/PanZoom.js | 2 +- tests/Control.html | 3 ++- tests/Control/PanZoomBar.html | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Control.js b/lib/OpenLayers/Control.js index 0323b07f34..7afa924a6d 100644 --- a/lib/OpenLayers/Control.js +++ b/lib/OpenLayers/Control.js @@ -229,6 +229,7 @@ OpenLayers.Control = OpenLayers.Class({ this.map.removeControl(this); this.map = null; } + this.div = null; }, /** diff --git a/lib/OpenLayers/Control/PanZoom.js b/lib/OpenLayers/Control/PanZoom.js index b1dabaebed..147c0c4b31 100644 --- a/lib/OpenLayers/Control/PanZoom.js +++ b/lib/OpenLayers/Control/PanZoom.js @@ -64,10 +64,10 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, { * APIMethod: destroy */ destroy: function() { - OpenLayers.Control.prototype.destroy.apply(this, arguments); this.removeButtons(); this.buttons = null; this.position = null; + OpenLayers.Control.prototype.destroy.apply(this, arguments); }, /** diff --git a/tests/Control.html b/tests/Control.html index 1d18a4cf00..06f057cd09 100644 --- a/tests/Control.html +++ b/tests/Control.html @@ -60,7 +60,7 @@ } function test_Control_destroy(t) { - t.plan(3); + t.plan(4); var map = new OpenLayers.Map('map'); var control = new OpenLayers.Control(); @@ -70,6 +70,7 @@ t.ok(map.controls[map.controls.length - 1] != control, "map.controls doesn't contains control"); t.ok(control.map == null, "Control.map is null"); + t.ok(control.div == null, "Control.div is null"); t.ok(control.handler == null, "Control.handler is null"); } diff --git a/tests/Control/PanZoomBar.html b/tests/Control/PanZoomBar.html index 9f38c89f6b..f80f36172e 100644 --- a/tests/Control/PanZoomBar.html +++ b/tests/Control/PanZoomBar.html @@ -44,8 +44,9 @@ control = new OpenLayers.Control.PanZoomBar(); map.addControl(control); control.removeButtons(); + var div = control.div; map.destroy(); - t.eq(control.div.childNodes.length, 0, "control's div cleared."); + t.eq(div.childNodes.length, 0, "control's div cleared."); t.eq(control.zoombarDiv, null, "zoombar div nullified.") }