Changeset 7941
- Timestamp:
- 09/03/08 15:16:29 (3 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer/Vector.js (modified) (2 diffs)
- trunk/openlayers/tests/Layer/Vector.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer/Vector.js
r7930 r7941 493 493 */ 494 494 removeFeatures: function(features, options) { 495 if(!features || features.length === 0) { 496 return; 497 } 495 498 if (!(features instanceof Array)) { 496 499 features = [features]; 497 }498 if (features.length <= 0) {499 return;500 500 } 501 501 … … 568 568 features = this.features; 569 569 } 570 this.removeFeatures(features, options); 571 for (var i = 0; i < features.length; i++) { 572 features[i].destroy(); 570 if(features) { 571 this.removeFeatures(features, options); 572 for(var i=features.length-1; i>=0; i--) { 573 features[i].destroy(); 574 } 573 575 } 574 576 }, trunk/openlayers/tests/Layer/Vector.html
r7930 r7941 239 239 240 240 function test_Layer_Vector_destroy (t) { 241 t.plan( 4);241 t.plan(5); 242 242 243 243 var options = {protocol: new OpenLayers.Protocol(), … … 253 253 t.eq(layer.protocol, null, "layer.protocol is null after destroy"); 254 254 t.eq(layer.strategies, null, "layer.strategies is null after destroy"); 255 256 // test that we can call layer.destroy a second time without trouble 257 try { 258 layer.destroy(); 259 layer.destroy(); 260 t.ok(true, "layer.destroy called twice without any issues"); 261 } catch(err) { 262 t.fail("calling layer.destroy twice triggers exception: " + err + " in " + err.fileName + " line " + err.lineNumber); 263 } 264 255 265 } 256 266
