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
This commit is contained in:
@@ -229,6 +229,7 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
this.map.removeControl(this);
|
||||
this.map = null;
|
||||
}
|
||||
this.div = null;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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.")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user