[OpenLayers-Commits] r5347 - in trunk/openlayers: lib/OpenLayers/Geometry tests/Geometry
commits at openlayers.org
commits at openlayers.org
Wed Dec 5 03:53:28 EST 2007
Author: tschaub
Date: 2007-12-05 03:53:27 -0500 (Wed, 05 Dec 2007)
New Revision: 5347
Modified:
trunk/openlayers/lib/OpenLayers/Geometry/Collection.js
trunk/openlayers/tests/Geometry/test_Collection.html
Log:
remove geometry components backwards - thanks for the catch flixo and review crschmidt (closes #1190).
Modified: trunk/openlayers/lib/OpenLayers/Geometry/Collection.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Geometry/Collection.js 2007-12-05 07:54:59 UTC (rev 5346)
+++ trunk/openlayers/lib/OpenLayers/Geometry/Collection.js 2007-12-05 08:53:27 UTC (rev 5347)
@@ -177,7 +177,7 @@
if(!(components instanceof Array)) {
components = [components];
}
- for (var i = 0; i < components.length; i++) {
+ for(var i=components.length-1; i>=0; --i) {
this.removeComponent(components[i]);
}
},
Modified: trunk/openlayers/tests/Geometry/test_Collection.html
===================================================================
--- trunk/openlayers/tests/Geometry/test_Collection.html 2007-12-05 07:54:59 UTC (rev 5346)
+++ trunk/openlayers/tests/Geometry/test_Collection.html 2007-12-05 08:53:27 UTC (rev 5347)
@@ -89,7 +89,7 @@
}
function test_04_Collection_removeComponents (t) {
- t.plan( 4 );
+ t.plan( 5 );
coll = new OpenLayers.Geometry.Collection();
point = new OpenLayers.Geometry.Point(0,0);
coll.addComponents(point);
@@ -100,6 +100,17 @@
bounds = coll.getBounds();
t.eq( bounds.left, 10, "left 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) {
More information about the Commits
mailing list