From 34959835fb1082b46193538f17292a29ed54e23c Mon Sep 17 00:00:00 2001 From: crschmidt Date: Sun, 21 Dec 2008 14:42:41 +0000 Subject: [PATCH] Map should deactivate removed controls, removal of pythonic lack of ';' caught by elemoine in his review. (Closes #1880) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8530 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Map.js | 1 + tests/Control.html | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 81e8b7882c..6f558c2e4b 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1130,6 +1130,7 @@ OpenLayers.Map = OpenLayers.Class({ removeControl: function (control) { //make sure control is non-null and actually part of our map if ( (control) && (control == this.getControl(control.id)) ) { + control.deactivate(); if (control.div && (control.div.parentNode == this.viewPortDiv)) { this.viewPortDiv.removeChild(control.div); } diff --git a/tests/Control.html b/tests/Control.html index 6bf6966258..ec0931a6b3 100644 --- a/tests/Control.html +++ b/tests/Control.html @@ -59,6 +59,16 @@ control2.destroy(); } + function test_Control_removeControl(t) { + t.plan(1); + var map = new OpenLayers.Map('map'); + var control = new OpenLayers.Control(); + map.addControl(control); + control.deactivate = function() { + t.ok(true, "Deactivate is called."); + }; + map.removeControl(control); + } function test_Control_destroy(t) { t.plan(3);