From 8874a6069feebde7374a5ce3ce0b2ea4c30e1c9a Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 14 Jun 2007 19:18:57 +0000 Subject: [PATCH] additional patch for #742 - removeControl() now takes the control as argument, not the id git-svn-id: http://svn.openlayers.org/trunk/openlayers@3329 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Map.js | 8 ++++---- tests/test_Map.html | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 5879d805e3..7446290b7a 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -621,11 +621,11 @@ OpenLayers.Map.prototype = { * object's internal array of controls, as well as from the map's * viewPort (assuming the control was not added outsideViewport) * - * @param {String} id ID of the control to remove + * @param {OpenLayers.Control} control control to remove */ - removeControl: function (id) { - var control = this.getControl(id); - if (control) { + removeControl: function (control) { + //make sure control is non-null and actually part of our map + if ( (control) && (control == this.getControl(control.id)) ) { if (!control.outsideViewport) { this.viewPortDiv.removeChild(control.div) } diff --git a/tests/test_Map.html b/tests/test_Map.html index 734cf75911..b6e14aa30a 100644 --- a/tests/test_Map.html +++ b/tests/test_Map.html @@ -431,7 +431,7 @@ t.ok(foundDiv, "new control's div correctly added to viewPort"); //remove control - map1.removeControl(control.id) + map1.removeControl(control) newNumControls = map1.controls.length; t.ok( newNumControls == oldNumControls, "removing the control decreases control count") @@ -448,7 +448,8 @@ t.ok(!foundDiv, "control no longer child of viewPort"); //remove bogus - map1.removeControl("bogus id"); + control = { id: "bogus id" }; + map1.removeControl(control); newNumControls = map1.controls.length; t.ok( newNumControls == oldNumControls, "removing bad controlid doesnt crash or decrease control count") }