Changeset 7938
- Timestamp:
- 09/03/08 10:15:26 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/Vector.js
r7875 r7938 482 482 */ 483 483 removeFeatures: function(features, options) { 484 if(!features || features.length === 0) { 485 return; 486 } 484 487 if (!(features instanceof Array)) { 485 488 features = [features]; 486 }487 if (features.length <= 0) {488 return;489 489 } 490 490 … … 556 556 features = this.features; 557 557 } 558 this.removeFeatures(features, options); 559 for (var i = 0; i < features.length; i++) { 560 features[i].destroy(); 558 if(features) { 559 this.removeFeatures(features, options); 560 for (var i = 0; i < features.length; i++) { 561 features[i].destroy(); 562 } 561 563 } 562 564 }, sandbox/camptocamp/unhcr/tests/Layer/Vector.html
r7827 r7938 258 258 259 259 function test_Layer_Vector_destroy (t) { 260 t.plan( 4);260 t.plan(5); 261 261 262 262 var options = {protocol: new OpenLayers.Protocol(), … … 272 272 t.eq(layer.protocol, null, "layer.protocol is null after destroy"); 273 273 t.eq(layer.strategies, null, "layer.strategies is null after destroy"); 274 275 // test that we can call layer.destroy a second time without trouble 276 try { 277 layer.destroy(); 278 layer.destroy(); 279 t.ok(true, "layer.destroy called twice without any issues"); 280 } catch(err) { 281 t.fail("calling layer.destroy twice triggers exception: " + err + " in " + err.fileName + " line " + err.lineNumber); 282 } 283 274 284 } 275 285
