[OpenLayers-Commits] r12095 - in trunk/openlayers: lib/OpenLayers lib/OpenLayers/Control lib/OpenLayers/Format lib/OpenLayers/Format/CSWGetDomain lib/OpenLayers/Format/CSWGetRecords lib/OpenLayers/Format/GML lib/OpenLayers/Format/OWSContext lib/OpenLayers/Format/SLD lib/OpenLayers/Format/WMC lib/OpenLayers/Format/WMSCapabilities lib/OpenLayers/Format/XLS lib/OpenLayers/Geometry lib/OpenLayers/Layer lib/OpenLayers/Protocol lib/OpenLayers/Protocol/SQL lib/OpenLayers/Renderer lib/OpenLayers/Tile tests

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Jun 16 15:16:27 EDT 2011


Author: tschaub
Date: 2011-06-16 12:16:25 -0700 (Thu, 16 Jun 2011)
New Revision: 12095

Modified:
   trunk/openlayers/lib/OpenLayers/Control/GetFeature.js
   trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js
   trunk/openlayers/lib/OpenLayers/Control/Panel.js
   trunk/openlayers/lib/OpenLayers/Control/SelectFeature.js
   trunk/openlayers/lib/OpenLayers/Control/WMSGetFeatureInfo.js
   trunk/openlayers/lib/OpenLayers/Control/WMTSGetFeatureInfo.js
   trunk/openlayers/lib/OpenLayers/Format/ArcXML.js
   trunk/openlayers/lib/OpenLayers/Format/Atom.js
   trunk/openlayers/lib/OpenLayers/Format/CSWGetDomain/v2_0_2.js
   trunk/openlayers/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js
   trunk/openlayers/lib/OpenLayers/Format/GML.js
   trunk/openlayers/lib/OpenLayers/Format/GML/Base.js
   trunk/openlayers/lib/OpenLayers/Format/GML/v2.js
   trunk/openlayers/lib/OpenLayers/Format/GML/v3.js
   trunk/openlayers/lib/OpenLayers/Format/GeoJSON.js
   trunk/openlayers/lib/OpenLayers/Format/GeoRSS.js
   trunk/openlayers/lib/OpenLayers/Format/KML.js
   trunk/openlayers/lib/OpenLayers/Format/OSM.js
   trunk/openlayers/lib/OpenLayers/Format/OWSContext/v0_3_1.js
   trunk/openlayers/lib/OpenLayers/Format/SLD/v1.js
   trunk/openlayers/lib/OpenLayers/Format/WMC.js
   trunk/openlayers/lib/OpenLayers/Format/WMC/v1.js
   trunk/openlayers/lib/OpenLayers/Format/WMSCapabilities/v1.js
   trunk/openlayers/lib/OpenLayers/Format/XLS/v1.js
   trunk/openlayers/lib/OpenLayers/Geometry.js
   trunk/openlayers/lib/OpenLayers/Geometry/Collection.js
   trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js
   trunk/openlayers/lib/OpenLayers/Layer/HTTPRequest.js
   trunk/openlayers/lib/OpenLayers/Layer/KaMapCache.js
   trunk/openlayers/lib/OpenLayers/Layer/MapServer.js
   trunk/openlayers/lib/OpenLayers/Layer/TMS.js
   trunk/openlayers/lib/OpenLayers/Layer/TileCache.js
   trunk/openlayers/lib/OpenLayers/Layer/Vector.js
   trunk/openlayers/lib/OpenLayers/Layer/WMTS.js
   trunk/openlayers/lib/OpenLayers/Layer/XYZ.js
   trunk/openlayers/lib/OpenLayers/Layer/Zoomify.js
   trunk/openlayers/lib/OpenLayers/Protocol/SQL/Gears.js
   trunk/openlayers/lib/OpenLayers/Protocol/WFS.js
   trunk/openlayers/lib/OpenLayers/Renderer.js
   trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js
   trunk/openlayers/lib/OpenLayers/Tile/Image.js
   trunk/openlayers/lib/OpenLayers/Util.js
   trunk/openlayers/tests/Util.html
Log:
More robust array type check.  p=mwootendev, r=me (closes #2959)

Modified: trunk/openlayers/lib/OpenLayers/Control/GetFeature.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/GetFeature.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Control/GetFeature.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -478,7 +478,7 @@
         if(!this.modifiers.multiple && !this.modifiers.toggle) {
             this.unselectAll();
         }
-        if(!(features instanceof Array)) {
+        if(!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
         

Modified: trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -215,7 +215,7 @@
         this.deleteCodes = [46, 68];
         this.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
         OpenLayers.Control.prototype.initialize.apply(this, [options]);
-        if(!(this.deleteCodes instanceof Array)) {
+        if(!(OpenLayers.Util.isArray(this.deleteCodes))) {
             this.deleteCodes = [this.deleteCodes];
         }
         var control = this;

Modified: trunk/openlayers/lib/OpenLayers/Control/Panel.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/Panel.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Control/Panel.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -232,7 +232,7 @@
      * controls - {<OpenLayers.Control>} Controls to add in the panel.
      */    
     addControls: function(controls) {
-        if (!(controls instanceof Array)) {
+        if (!(OpenLayers.Util.isArray(controls))) {
             controls = [controls];
         }
         this.controls = this.controls.concat(controls);

Modified: trunk/openlayers/lib/OpenLayers/Control/SelectFeature.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/SelectFeature.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Control/SelectFeature.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -218,7 +218,7 @@
      * layers - {<OpenLayers.Layer.Vector>}, or an array of vector layers.
      */
     initLayer: function(layers) {
-        if(layers instanceof Array) {
+        if(OpenLayers.Util.isArray(layers)) {
             this.layers = layers;
             this.layer = new OpenLayers.Layer.Vector.RootContainer(
                 this.id + "_container", {

Modified: trunk/openlayers/lib/OpenLayers/Control/WMSGetFeatureInfo.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/WMSGetFeatureInfo.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Control/WMSGetFeatureInfo.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -300,7 +300,7 @@
             layer = candidates[i];
             if(layer instanceof OpenLayers.Layer.WMS &&
                (!this.queryVisible || layer.getVisibility())) {
-                url = layer.url instanceof Array ? layer.url[0] : layer.url;
+                url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;
                 // if the control was not configured with a url, set it
                 // to the first layer url
                 if(this.drillDown === false && !this.url) {
@@ -421,7 +421,7 @@
         if (layer.params.STYLES) {
             styleNames = layer.params.STYLES;
         } else {
-            if (layer.params.LAYERS instanceof Array) {
+            if (OpenLayers.Util.isArray(layer.params.LAYERS)) {
                 styleNames = new Array(layer.params.LAYERS.length);
             } else { // Assume it's a String
                 styleNames = layer.params.LAYERS.replace(/[^,]/g, "");
@@ -469,7 +469,7 @@
             for(var i=0, len=layers.length; i<len; i++) {
                 var layer = layers[i];
                 var service, found = false;
-                url = layer.url instanceof Array ? layer.url[0] : layer.url;
+                url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;
                 if(url in services) {
                     services[url].push(layer);
                 } else {

Modified: trunk/openlayers/lib/OpenLayers/Control/WMTSGetFeatureInfo.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/WMTSGetFeatureInfo.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Control/WMTSGetFeatureInfo.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -299,7 +299,7 @@
         });
         OpenLayers.Util.applyDefaults(params, this.vendorParams);
         return {
-            url: layer.url instanceof Array ? layer.url[0] : layer.url,
+            url: OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url,
             params: OpenLayers.Util.upperCaseObject(params),
             callback: function(request) {
                 this.handleResponse(xy, request, layer);

Modified: trunk/openlayers/lib/OpenLayers/Format/ArcXML.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/ArcXML.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/ArcXML.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -496,7 +496,7 @@
     
     
     addRenderer: function(topRelem, renderer) {
-        if (renderer instanceof Array) {
+        if (OpenLayers.Util.isArray(renderer)) {
             this.addGroupRenderer(topRelem, renderer);
         } else {
             var renderElem = this.createElementNS("", renderer.type.toUpperCase() + "RENDERER");

Modified: trunk/openlayers/lib/OpenLayers/Format/Atom.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/Atom.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/Atom.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -99,7 +99,7 @@
      */
     write: function(features) {
         var doc;
-        if (features instanceof Array) {
+        if (OpenLayers.Util.isArray(features)) {
             doc = this.createElementNSPlus("atom:feed");
             doc.appendChild(
                 this.createElementNSPlus("atom:title", {
@@ -183,7 +183,7 @@
         
         // atom:author
         if (atomAttrib.authors) {
-            var authors = atomAttrib.authors instanceof Array ?
+            var authors = OpenLayers.Util.isArray(atomAttrib.authors) ?
                 atomAttrib.authors : [atomAttrib.authors];
             for (var i=0, ii=authors.length; i<ii; i++) {
                 entryNode.appendChild(
@@ -196,7 +196,7 @@
         
         // atom:category
         if (atomAttrib.categories) {
-            var categories = atomAttrib.categories instanceof Array ?
+            var categories = OpenLayers.Util.isArray(atomAttrib.categories) ?
                 atomAttrib.categories : [atomAttrib.categories];
             var category;
             for (var i=0, ii=categories.length; i<ii; i++) {
@@ -220,7 +220,7 @@
         
         // atom:contributor
         if (atomAttrib.contributors) {
-            var contributors = atomAttrib.contributors instanceof Array ?
+            var contributors = OpenLayers.Util.isArray(atomAttrib.contributors) ?
                 atomAttrib.contributors : [atomAttrib.contributors];
             for (var i=0, ii=contributors.length; i<ii; i++) {
                 entryNode.appendChild(
@@ -243,7 +243,7 @@
         
         // atom:link
         if (atomAttrib.links) {
-            var links = atomAttrib.links instanceof Array ?
+            var links = OpenLayers.Util.isArray(atomAttrib.links) ?
                 atomAttrib.links : [atomAttrib.links];
             var link;
             for (var i=0, ii=links.length; i<ii; i++) {

Modified: trunk/openlayers/lib/OpenLayers/Format/CSWGetDomain/v2_0_2.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/CSWGetDomain/v2_0_2.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/CSWGetDomain/v2_0_2.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -108,7 +108,7 @@
                 this.readChildNodes(node, obj);
             },
             "DomainValues": function(node, obj) {
-                if (!(obj.DomainValues instanceof Array)) {
+                if (!(OpenLayers.Util.isArray(obj.DomainValues))) {
                     obj.DomainValues = [];
                 }
                 var attrs = node.attributes;
@@ -126,7 +126,7 @@
                 obj.ParameterName = this.getChildValue(node);
             },
             "ListOfValues": function(node, obj) {
-                if (!(obj.ListOfValues instanceof Array)) {
+                if (!(OpenLayers.Util.isArray(obj.ListOfValues))) {
                     obj.ListOfValues = [];
                 }
                 this.readChildNodes(node, obj.ListOfValues);

Modified: trunk/openlayers/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -253,7 +253,7 @@
             // rightsHolder, source, subject, title, type, URI
             "*": function(node, obj) {
                 var name = node.localName || node.nodeName.split(":").pop();
-                if (!(obj[name] instanceof Array)) {
+                if (!(OpenLayers.Util.isArray(obj[name]))) {
                     obj[name] = new Array();
                 }
                 var dc_element = {};
@@ -269,7 +269,7 @@
             // abstract, modified, spatial
             "*": function(node, obj) {
                 var name = node.localName || node.nodeName.split(":").pop();
-                if (!(obj[name] instanceof Array)) {
+                if (!(OpenLayers.Util.isArray(obj[name]))) {
                     obj[name] = new Array();
                 }
                 obj[name].push(this.getChildValue(node));
@@ -342,7 +342,7 @@
                     );
                 }
                 var ResponseHandler = options.ResponseHandler || this.ResponseHandler;
-                if (ResponseHandler instanceof Array && ResponseHandler.length > 0) {
+                if (OpenLayers.Util.isArray(ResponseHandler) && ResponseHandler.length > 0) {
                     // ResponseHandler must be a non-empty array
                     for(var i=0, len=ResponseHandler.length; i<len; i++) {
                         this.writeNode(
@@ -379,7 +379,7 @@
                     }
                 });
                 var ElementName = options.ElementName;
-                if (ElementName instanceof Array && ElementName.length > 0) {
+                if (OpenLayers.Util.isArray(ElementName) && ElementName.length > 0) {
                     // ElementName must be a non-empty array
                     for(var i=0, len=ElementName.length; i<len; i++) {
                         this.writeNode(

Modified: trunk/openlayers/lib/OpenLayers/Format/GML/Base.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/GML/Base.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/GML/Base.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -419,7 +419,7 @@
      */
     write: function(features) {
         var name;
-        if(features instanceof Array) {
+        if(OpenLayers.Util.isArray(features)) {
             name = "featureMembers";
         } else {
             name = "featureMember";

Modified: trunk/openlayers/lib/OpenLayers/Format/GML/v2.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/GML/v2.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/GML/v2.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -90,7 +90,7 @@
      */
     write: function(features) {
         var name;
-        if(features instanceof Array) {
+        if(OpenLayers.Util.isArray(features)) {
             // GML2 only has abstract feature collections
             // wfs provides a feature collection from a well-known schema
             name = "wfs:FeatureCollection";

Modified: trunk/openlayers/lib/OpenLayers/Format/GML/v3.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/GML/v3.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/GML/v3.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -250,7 +250,7 @@
      */
     write: function(features) {
         var name;
-        if(features instanceof Array) {
+        if(OpenLayers.Util.isArray(features)) {
             name = "featureMembers";
         } else {
             name = "featureMember";

Modified: trunk/openlayers/lib/OpenLayers/Format/GML.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/GML.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/GML.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -639,7 +639,7 @@
      * {String} A string representing the GML document.
      */
     write: function(features) {
-        if(!(features instanceof Array)) {
+        if(!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
         var gml = this.createElementNS("http://www.opengis.net/wfs",

Modified: trunk/openlayers/lib/OpenLayers/Format/GeoJSON.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/GeoJSON.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/GeoJSON.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -219,7 +219,7 @@
         }
         var geometry, collection = false;
         if(obj.type == "GeometryCollection") {
-            if(!(obj.geometries instanceof Array)) {
+            if(!(OpenLayers.Util.isArray(obj.geometries))) {
                 throw "GeometryCollection must have geometries array: " + obj;
             }
             var numGeom = obj.geometries.length;
@@ -232,7 +232,7 @@
             geometry = new OpenLayers.Geometry.Collection(components);
             collection = true;
         } else {
-            if(!(obj.coordinates instanceof Array)) {
+            if(!(OpenLayers.Util.isArray(obj.coordinates))) {
                 throw "Geometry must have coordinates array: " + obj;
             }
             if(!this.parseCoords[obj.type.toLowerCase()]) {
@@ -450,7 +450,7 @@
         var geojson = {
             "type": null
         };
-        if(obj instanceof Array) {
+        if(OpenLayers.Util.isArray(obj)) {
             geojson.type = "FeatureCollection";
             var numFeatures = obj.length;
             geojson.features = new Array(numFeatures);

Modified: trunk/openlayers/lib/OpenLayers/Format/GeoRSS.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/GeoRSS.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/GeoRSS.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -297,7 +297,7 @@
      */
     write: function(features) {
         var georss;
-        if(features instanceof Array) {
+        if(OpenLayers.Util.isArray(features)) {
             georss = this.createElementNS(this.rssns, "rss");
             for(var i=0, len=features.length; i<len; i++) {
                 georss.appendChild(this.createFeatureXML(features[i]));

Modified: trunk/openlayers/lib/OpenLayers/Format/KML.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/KML.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/KML.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -1131,7 +1131,7 @@
      * {String} A KML string.
      */
     write: function(features) {
-        if(!(features instanceof Array)) {
+        if(!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
         var kml = this.createElementNS(this.kmlns, "kml");

Modified: trunk/openlayers/lib/OpenLayers/Format/OSM.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/OSM.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/OSM.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -291,7 +291,7 @@
      * features - {Array(<OpenLayers.Feature.Vector>)}
      */
     write: function(features) { 
-        if (!(features instanceof Array)) {
+        if (!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
         

Modified: trunk/openlayers/lib/OpenLayers/Format/OWSContext/v0_3_1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/OWSContext/v0_3_1.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/OWSContext/v0_3_1.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -178,7 +178,7 @@
      */
     decomposeNestingPath: function(nPath){
         var a = [];
-        if (nPath instanceof Array) {
+        if (OpenLayers.Util.isArray(nPath)) {
             var path = nPath.slice();
             while (path.length > 0) {
                 a.push(path.slice());

Modified: trunk/openlayers/lib/OpenLayers/Format/SLD/v1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/SLD/v1.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/SLD/v1.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -147,7 +147,7 @@
                 for(var i=0, len=layer.userStyles.length; i<len; ++i) {
                     layer.userStyles[i].layerName = layer.name;
                 }
-                if(sld.namedLayers instanceof Array) {
+                if(OpenLayers.Util.isArray(sld.namedLayers)) {
                     sld.namedLayers.push(layer);                
                 } else {
                     sld.namedLayers[layer.name] = layer;
@@ -558,7 +558,7 @@
                 }
                 // add in named layers
                 // allow namedLayers to be an array
-                if(sld.namedLayers instanceof Array) {
+                if(OpenLayers.Util.isArray(sld.namedLayers)) {
                     for(var i=0, len=sld.namedLayers.length; i<len; ++i) {
                         this.writeNode("NamedLayer", sld.namedLayers[i], root);
                     }

Modified: trunk/openlayers/lib/OpenLayers/Format/WMC/v1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/WMC/v1.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/WMC/v1.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -1154,7 +1154,7 @@
         var node = this.createElementDefaultNS("StyleList");
 
         var styles = layer.styles;
-        if (styles && styles instanceof Array) {
+        if (styles && OpenLayers.Util.isArray(styles)) {
             var sld;
             for (var i=0, len=styles.length; i<len; i++) {
                 var s = styles[i];

Modified: trunk/openlayers/lib/OpenLayers/Format/WMC.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/WMC.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/WMC.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -191,7 +191,7 @@
         }
 
         // let's convert layers into layersContext object (if any)
-        if (layers != undefined && layers instanceof Array) {
+        if (layers != undefined && OpenLayers.Util.isArray(layers)) {
             for (var i=0, len=layers.length; i<len; i++) {
                 var layer = layers[i];
                 if (layer instanceof OpenLayers.Layer.WMS) {

Modified: trunk/openlayers/lib/OpenLayers/Format/WMSCapabilities/v1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/WMSCapabilities/v1.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/WMSCapabilities/v1.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -296,7 +296,7 @@
                 this.readChildNodes(node, obj.getcapabilities);
             },
             "Format": function(node, obj) {
-                if (obj.formats instanceof Array) {
+                if (OpenLayers.Util.isArray(obj.formats)) {
                     obj.formats.push(this.getChildValue(node));
                 } else {
                     obj.format = this.getChildValue(node);

Modified: trunk/openlayers/lib/OpenLayers/Format/XLS/v1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/XLS/v1.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Format/XLS/v1.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -258,7 +258,7 @@
                     this.writeNode(node, "Building", address.building);
                 }
                 var street = address.street;
-                if (!(street instanceof Array)) {
+                if (!(OpenLayers.Util.isArray(street))) {
                     street = [street];
                 }
                 for (var i=0, len=street.length; i < len; i++) {

Modified: trunk/openlayers/lib/OpenLayers/Geometry/Collection.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Geometry/Collection.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Geometry/Collection.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -131,7 +131,7 @@
      * components - {Array(<OpenLayers.Geometry>)} An array of geometries to add
      */
     addComponents: function(components){
-        if(!(components instanceof Array)) {
+        if(!(OpenLayers.Util.isArray(components))) {
             components = [components];
         }
         for(var i=0, len=components.length; i<len; i++) {
@@ -185,7 +185,7 @@
      * components - {Array(<OpenLayers.Geometry>)} The components to be removed
      */
     removeComponents: function(components) {
-        if(!(components instanceof Array)) {
+        if(!(OpenLayers.Util.isArray(components))) {
             components = [components];
         }
         for(var i=components.length-1; i>=0; --i) {
@@ -468,7 +468,7 @@
         if(!geometry || !geometry.CLASS_NAME ||
            (this.CLASS_NAME != geometry.CLASS_NAME)) {
             equivalent = false;
-        } else if(!(geometry.components instanceof Array) ||
+        } else if(!(OpenLayers.Util.isArray(geometry.components)) ||
                   (geometry.components.length != this.components.length)) {
             equivalent = false;
         } else {

Modified: trunk/openlayers/lib/OpenLayers/Geometry.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Geometry.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Geometry.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -274,7 +274,7 @@
     var result = format.read(wkt);
     if(result instanceof OpenLayers.Feature.Vector) {
         geom = result.geometry;
-    } else if(result instanceof Array) {
+    } else if(OpenLayers.Util.isArray(result)) {
         var len = result.length;
         var components = new Array(len);
         for(var i=0; i<len; ++i) {

Modified: trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/ArcGISCache.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -430,7 +430,7 @@
         var url = this.url;
         var s = '' + x + y + z;
 
-        if (url instanceof Array) {
+        if (OpenLayers.Util.isArray(url)) {
             url = this.selectUrl(s, url);
         }
 

Modified: trunk/openlayers/lib/OpenLayers/Layer/HTTPRequest.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/HTTPRequest.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/HTTPRequest.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -209,7 +209,7 @@
         // in which case we will deterministically select one of them in 
         // order to evenly distribute requests to different urls.
         //
-        if (url instanceof Array) {
+        if (OpenLayers.Util.isArray(url)) {
             url = this.selectUrl(paramsString, url);
         }   
  

Modified: trunk/openlayers/lib/OpenLayers/Layer/KaMapCache.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/KaMapCache.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/KaMapCache.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -117,7 +117,7 @@
         // order to evenly distribute requests to different urls.
         //
         var url = this.url;
-        if (url instanceof Array) {
+        if (OpenLayers.Util.isArray(url)) {
             url = this.selectUrl(paramsString, url);
         }  
     

Modified: trunk/openlayers/lib/OpenLayers/Layer/MapServer.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/MapServer.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/MapServer.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -136,7 +136,7 @@
         // if url is not a string, it should be an array of strings, 
         // in which case we will deterministically select one of them in 
         // order to evenly distribute requests to different urls.
-        if (url instanceof Array) {
+        if (OpenLayers.Util.isArray(url)) {
             url = this.selectUrl(paramsString, url);
         }   
         

Modified: trunk/openlayers/lib/OpenLayers/Layer/TMS.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/TMS.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/TMS.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -129,7 +129,7 @@
             this.map.getZoom() + this.zoomOffset;
         var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; 
         var url = this.url;
-        if (url instanceof Array) {
+        if (OpenLayers.Util.isArray(url)) {
             url = this.selectUrl(path, url);
         }
         return url + path;

Modified: trunk/openlayers/lib/OpenLayers/Layer/TileCache.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/TileCache.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/TileCache.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -138,7 +138,7 @@
         ];
         var path = components.join('/'); 
         var url = this.url;
-        if (url instanceof Array) {
+        if (OpenLayers.Util.isArray(url)) {
             url = this.selectUrl(path, url);
         }
         url = (url.charAt(url.length - 1) == '/') ? url : url + '/';

Modified: trunk/openlayers/lib/OpenLayers/Layer/Vector.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Vector.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/Vector.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -554,7 +554,7 @@
      * options - {Object}
      */
     addFeatures: function(features, options) {
-        if (!(features instanceof Array)) {
+        if (!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
         
@@ -643,7 +643,7 @@
         if (features === this.features) {
             return this.removeAllFeatures(options);
         }
-        if (!(features instanceof Array)) {
+        if (!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
         if (features === this.selectedFeatures) {

Modified: trunk/openlayers/lib/OpenLayers/Layer/WMTS.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/WMTS.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/WMTS.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -408,7 +408,7 @@
                 path = path + this.matrixSet + "/" + this.matrix.identifier + 
                     "/" + info.row + "/" + info.col + "." + this.formatSuffix;
                 
-                if (this.url instanceof Array) {
+                if (OpenLayers.Util.isArray(this.url)) {
                     url = this.selectUrl(path, this.url);
                 } else {
                     url = this.url;

Modified: trunk/openlayers/lib/OpenLayers/Layer/XYZ.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/XYZ.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/XYZ.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -120,7 +120,7 @@
     getURL: function (bounds) {
         var xyz = this.getXYZ(bounds);
         var url = this.url;
-        if (url instanceof Array) {
+        if (OpenLayers.Util.isArray(url)) {
             var s = '' + xyz.x + xyz.y + xyz.z;
             url = this.selectUrl(s, url);
         }

Modified: trunk/openlayers/lib/OpenLayers/Layer/Zoomify.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Zoomify.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Layer/Zoomify.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -211,7 +211,7 @@
         var path = "TileGroup" + Math.floor( (tileIndex) / 256 ) +
             "/" + z + "-" + x + "-" + y + ".jpg";
         var url = this.url;
-        if (url instanceof Array) {
+        if (OpenLayers.Util.isArray(url)) {
             url = this.selectUrl(path, url);
         }
         return url + path;

Modified: trunk/openlayers/lib/OpenLayers/Protocol/SQL/Gears.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Protocol/SQL/Gears.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Protocol/SQL/Gears.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -302,7 +302,7 @@
      *          object.
      */
     createOrUpdate: function(features) {
-        if (!(features instanceof Array)) {
+        if (!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
 
@@ -397,7 +397,7 @@
      *          object.
      */
     "delete": function(features, options) {
-        if (!(features instanceof Array)) {
+        if (!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
 

Modified: trunk/openlayers/lib/OpenLayers/Protocol/WFS.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Protocol/WFS.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Protocol/WFS.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -45,7 +45,7 @@
 OpenLayers.Protocol.WFS.fromWMSLayer = function(layer, options) {
     var typeName, featurePrefix;
     var param = layer.params["LAYERS"];
-    var parts = (param instanceof Array ? param[0] : param).split(":");
+    var parts = (OpenLayers.Util.isArray(param) ? param[0] : param).split(":");
     if(parts.length > 1) {
         featurePrefix = parts[0];
     }

Modified: trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -632,7 +632,7 @@
      * features - {Array(<OpenLayers.Feature.Vector>)} 
      */
     eraseFeatures: function(features) {
-        if(!(features instanceof Array)) {
+        if(!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
         for(var i=0; i<features.length; ++i) {

Modified: trunk/openlayers/lib/OpenLayers/Renderer.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Renderer.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Renderer.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -267,7 +267,7 @@
      * features - {Array(<OpenLayers.Feature.Vector>)} 
      */
     eraseFeatures: function(features) {
-        if(!(features instanceof Array)) {
+        if(!(OpenLayers.Util.isArray(features))) {
             features = [features];
         }
         for(var i=0, len=features.length; i<len; ++i) {

Modified: trunk/openlayers/lib/OpenLayers/Tile/Image.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Tile/Image.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Tile/Image.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -373,7 +373,7 @@
             }
 
             // needed for changing to a different server for onload error
-            if (this.layer.url instanceof Array) {
+            if (OpenLayers.Util.isArray(this.layer.url)) {
                 this.imgDiv.urls = this.layer.url.slice();
             }
       

Modified: trunk/openlayers/lib/OpenLayers/Util.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Util.js	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/lib/OpenLayers/Util.js	2011-06-16 19:16:25 UTC (rev 12095)
@@ -58,6 +58,22 @@
     return !!(o && o.nodeType === 1);
 };
 
+/**
+ * Function: isArray
+ * Tests that the provided object is an array.
+ * This test handles the cross-IFRAME case not caught
+ * by "a instanceof Array" and should be used instead.
+ * 
+ * Parameters:
+ * a - {Object} the object test.
+ * 
+ * Returns
+ * {Boolean} true if the object is an array.
+ */
+OpenLayers.Util.isArray = function(a) {
+	return (Object.prototype.toString.call(a) === '[object Array]');
+};
+
 /** 
  * Maintain existing definition of $.
  */
@@ -346,7 +362,7 @@
     this._attempts = (this._attempts) ? (this._attempts + 1) : 1;
     if (this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
         var urls = this.urls;
-        if (urls && urls instanceof Array && urls.length > 1){
+        if (urls && OpenLayers.Util.isArray(urls) && urls.length > 1){
             var src = this.src.toString();
             var current_url, k;
             for (k = 0; current_url = urls[k]; k++){

Modified: trunk/openlayers/tests/Util.html
===================================================================
--- trunk/openlayers/tests/Util.html	2011-06-16 17:10:03 UTC (rev 12094)
+++ trunk/openlayers/tests/Util.html	2011-06-16 19:16:25 UTC (rev 12095)
@@ -41,6 +41,28 @@
              "isElement reports that object returned by getElement is an Element");
     }
     
+    function test_isArray(t) {
+        t.plan(5);
+        
+        var a;
+        
+        a = null;
+        t.eq(OpenLayers.Util.isArray(a), false, 
+             "isArray reports 'null' isn't an Array");
+        a = "Array";   
+        t.eq(OpenLayers.Util.isArray(a), false, 
+             "isArray reports \"Array\" isn't an Array");
+        a = {};
+        t.eq(OpenLayers.Util.isArray(a), false, 
+             "isArray reports {} isn't an Array");
+        a = [];
+        t.eq(OpenLayers.Util.isArray(a), true, 
+             "isArray reports [] is an Array");
+        a = new Array();
+        t.eq(OpenLayers.Util.isArray(a), true, 
+             "isArray reports new Array() is an Array");
+    }
+    
     function test_$(t) {
         t.plan(1);
         t.ok($ === custom$, "OpenLayers doesn't clobber existing definition of $.");



More information about the Commits mailing list