diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 610ad5a200..6737fefab2 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -243,7 +243,7 @@ OpenLayers.Layer.Grid.prototype = var iRow = 0; var iCell = -1; - var direction = directions.indexOf("right"); + var direction = OpenLayers.Util.indexOf(directions, "right"); var directionsTried = 0; while( directionsTried < directions.length) { diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index d70041b47d..6712d8b86e 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -359,7 +359,7 @@ OpenLayers.Map.prototype = { if (newBaseLayer != oldBaseLayer) { // is newBaseLayer an already loaded layer? - if (this.layers.indexOf(newBaseLayer) != -1) { + if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) { // make the old base layer invisible if (oldBaseLayer != null) { diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 45e84050a9..639b1a8abe 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -60,6 +60,21 @@ OpenLayers.Util.clearArray = function(array) { array.length = 0; }; +/** Seems to exist already in FF, but not in MOZ. + * + * @param {Array} array + * @param {Object} obj + */ +OpenLayers.Util.indexOf = function(array, obj) { + + for(var i=0; i < array.length; i++) { + if (array[i] == obj) return i; + } + return -1; +}; + + + /** * @param {String} id * @param {OpenLayers.Pixel} px diff --git a/tests/test_Map.html b/tests/test_Map.html index 29f0f69c3f..15d6554ee4 100644 --- a/tests/test_Map.html +++ b/tests/test_Map.html @@ -125,7 +125,8 @@ map.setCenter(new OpenLayers.LonLat(0, 0), 0); map.addPopup(popup); - t.eq(map.popups.indexOf(popup), 0, "popup successfully added to Map's internal popups array"); + var pIndex = OpenLayers.Util.indexOf(map.popups, popup); + t.eq(pIndex, 0, "popup successfully added to Map's internal popups array"); var nodes = map.layerContainerDiv.childNodes; @@ -140,7 +141,8 @@ map.removePopup(popup); - t.eq(map.popups.indexOf(popup), -1, "popup successfully removed from Map's internal popups array"); + var pIndex = OpenLayers.Util.indexOf(map.popups, popup); + t.eq(pIndex, -1, "popup successfully removed from Map's internal popups array"); var found = false; for (var i=0; i < nodes.length; i++) {