Changeset 5543
- Timestamp:
- 12/20/07 15:22:36 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Util.js (modified) (1 diff)
- trunk/openlayers/tests/test_Util.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Util.js
r5393 r5543 83 83 */ 84 84 OpenLayers.Util.removeItem = function(array, item) { 85 for(var i =0; i < array.length; i++) {85 for(var i = array.length - 1; i >= 0; i--) { 86 86 if(array[i] == item) { 87 87 array.splice(i,1); trunk/openlayers/tests/test_Util.html
r5491 r5543 13 13 14 14 function test_03_Util_Array(t) { 15 t.plan( 1);16 17 var array = new Array(1,2,3,4, 5);15 t.plan( 2 ); 16 17 var array = new Array(1,2,3,4,4,5); 18 18 19 19 OpenLayers.Util.removeItem(array, 3); 20 t.eq( array.toString(), "1,2,4,5", "Util.removeItem works"); 20 t.eq( array.toString(), "1,2,4,4,5", "Util.removeItem works on one element"); 21 OpenLayers.Util.removeItem(array, 4); 22 t.eq( array.toString(), "1,2,5", "Util.removeItem works on more than one element "); 21 23 } 22 24
