Ticket #742: controlGetRemove.2.patch
| File controlGetRemove.2.patch, 1.8 kB (added by euzuro, 1 year ago) |
|---|
-
tests/test_Map.html
old new 431 431 t.ok(foundDiv, "new control's div correctly added to viewPort"); 432 432 433 433 //remove control 434 map1.removeControl(control .id)434 map1.removeControl(control) 435 435 newNumControls = map1.controls.length; 436 436 t.ok( newNumControls == oldNumControls, "removing the control decreases control count") 437 437 … … 448 448 t.ok(!foundDiv, "control no longer child of viewPort"); 449 449 450 450 //remove bogus 451 map1.removeControl("bogus id"); 451 control = { id: "bogus id" }; 452 map1.removeControl(control); 452 453 newNumControls = map1.controls.length; 453 454 t.ok( newNumControls == oldNumControls, "removing bad controlid doesnt crash or decrease control count") 454 455 } -
lib/OpenLayers/Map.js
old new 621 621 * object's internal array of controls, as well as from the map's 622 622 * viewPort (assuming the control was not added outsideViewport) 623 623 * 624 * @param { String} id ID of thecontrol to remove624 * @param {OpenLayers.Control} control control to remove 625 625 */ 626 removeControl: function ( id) {627 var control = this.getControl(id);628 if ( control) {626 removeControl: function (control) { 627 //make sure control is non-null and actually part of our map 628 if ( (control) && (control == this.getControl(control.id)) ) { 629 629 if (!control.outsideViewport) { 630 630 this.viewPortDiv.removeChild(control.div) 631 631 }
