remove geometry components backwards - thanks for the catch flixo and review crschmidt (closes #1190).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5347 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -177,7 +177,7 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
|
|||||||
if(!(components instanceof Array)) {
|
if(!(components instanceof Array)) {
|
||||||
components = [components];
|
components = [components];
|
||||||
}
|
}
|
||||||
for (var i = 0; i < components.length; i++) {
|
for(var i=components.length-1; i>=0; --i) {
|
||||||
this.removeComponent(components[i]);
|
this.removeComponent(components[i]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_04_Collection_removeComponents (t) {
|
function test_04_Collection_removeComponents (t) {
|
||||||
t.plan( 4 );
|
t.plan( 5 );
|
||||||
coll = new OpenLayers.Geometry.Collection();
|
coll = new OpenLayers.Geometry.Collection();
|
||||||
point = new OpenLayers.Geometry.Point(0,0);
|
point = new OpenLayers.Geometry.Point(0,0);
|
||||||
coll.addComponents(point);
|
coll.addComponents(point);
|
||||||
@@ -100,6 +100,17 @@
|
|||||||
bounds = coll.getBounds();
|
bounds = coll.getBounds();
|
||||||
t.eq( bounds.left, 10, "left bound is 10 after removeComponent" );
|
t.eq( bounds.left, 10, "left bound is 10 after removeComponent" );
|
||||||
t.eq( bounds.bottom, 10, "bottom bound is 10 after removeComponent" );
|
t.eq( bounds.bottom, 10, "bottom bound is 10 after removeComponent" );
|
||||||
|
|
||||||
|
coll = new OpenLayers.Geometry.Collection();
|
||||||
|
for(var i=0; i<5; ++i) {
|
||||||
|
coll.addComponents(
|
||||||
|
new OpenLayers.Geometry.Point(Math.random(), Math.random())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
coll.removeComponents(coll.components);
|
||||||
|
t.eq(coll.components.length, 0,
|
||||||
|
"remove components even works with multiple components");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_06_Collection_calculateBounds(t) {
|
function test_06_Collection_calculateBounds(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user