OpenLayers OpenLayers

Changeset 7938

Show
Ignore:
Timestamp:
09/03/08 10:15:26 (3 months ago)
Author:
elemoine
Message:

apply patch attached to #1697

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/Vector.js

    r7875 r7938  
    482482     */ 
    483483    removeFeatures: function(features, options) { 
     484        if(!features || features.length === 0) { 
     485            return; 
     486        } 
    484487        if (!(features instanceof Array)) { 
    485488            features = [features]; 
    486         } 
    487         if (features.length <= 0) { 
    488             return; 
    489489        } 
    490490 
     
    556556            features = this.features; 
    557557        } 
    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            } 
    561563        } 
    562564    }, 
  • sandbox/camptocamp/unhcr/tests/Layer/Vector.html

    r7827 r7938  
    258258 
    259259    function test_Layer_Vector_destroy (t) { 
    260         t.plan(4);     
     260        t.plan(5);     
    261261 
    262262        var options = {protocol: new OpenLayers.Protocol(),  
     
    272272        t.eq(layer.protocol, null, "layer.protocol is null after destroy"); 
    273273        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         
    274284    } 
    275285