OpenLayers OpenLayers

Changeset 5347

Show
Ignore:
Timestamp:
12/05/07 03:53:27 (1 year ago)
Author:
tschaub
Message:

remove geometry components backwards - thanks for the catch flixo and review crschmidt (closes #1190).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Geometry/Collection.js

    r5200 r5347  
    178178            components = [components]; 
    179179        } 
    180         for (var i = 0; i < components.length; i++) { 
     180        for(var i=components.length-1; i>=0; --i) { 
    181181            this.removeComponent(components[i]); 
    182182        } 
  • trunk/openlayers/tests/Geometry/test_Collection.html

    r4707 r5347  
    9090 
    9191    function test_04_Collection_removeComponents (t) { 
    92         t.plan( 4 ); 
     92        t.plan( 5 ); 
    9393        coll = new OpenLayers.Geometry.Collection(); 
    9494        point = new OpenLayers.Geometry.Point(0,0); 
     
    101101        t.eq( bounds.left, 10, "left bound is 10 after removeComponent" ); 
    102102        t.eq( bounds.bottom, 10, "bottom bound is 10 after removeComponent" ); 
     103         
     104        coll = new OpenLayers.Geometry.Collection(); 
     105        for(var i=0; i<5; ++i) { 
     106            coll.addComponents( 
     107                new OpenLayers.Geometry.Point(Math.random(), Math.random()) 
     108            ); 
     109        } 
     110        coll.removeComponents(coll.components); 
     111        t.eq(coll.components.length, 0, 
     112             "remove components even works with multiple components"); 
     113         
    103114    } 
    104115