diff --git a/lib/OpenLayers/BaseTypes/Class.js b/lib/OpenLayers/BaseTypes/Class.js index 4a900b4198..1e242f55bb 100644 --- a/lib/OpenLayers/BaseTypes/Class.js +++ b/lib/OpenLayers/BaseTypes/Class.js @@ -91,9 +91,11 @@ OpenLayers.Util.extend = function(destination, source) { destination = destination || {}; if (source) { for (var property in source) { - var value = source[property]; - if (value !== undefined) { - destination[property] = value; + if (source.hasOwnProperty(property)) { + var value = source[property]; + if (value !== undefined) { + destination[property] = value; + } } } diff --git a/lib/OpenLayers/Control/GetFeature.js b/lib/OpenLayers/Control/GetFeature.js index c037f87d15..49760b03d3 100644 --- a/lib/OpenLayers/Control/GetFeature.js +++ b/lib/OpenLayers/Control/GetFeature.js @@ -258,7 +258,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { activate: function () { if (!this.active) { for(var i in this.handlers) { - this.handlers[i].activate(); + if (this.handlers.hasOwnProperty(i)) { + this.handlers[i].activate(); + } } } return OpenLayers.Control.prototype.activate.apply( @@ -276,7 +278,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { deactivate: function () { if (this.active) { for(var i in this.handlers) { - this.handlers[i].deactivate(); + if (this.handlers.hasOwnProperty(i)) { + this.handlers[i].deactivate(); + } } } return OpenLayers.Control.prototype.deactivate.apply( @@ -560,7 +564,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { unselectAll: function() { // we'll want an option to supress notification here for(var fid in this.features) { - this.unselect(this.features[fid]); + if (this.features.hasOwnProperty(fid)) { + this.unselect(this.features[fid]); + } } }, @@ -573,7 +579,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { */ setMap: function(map) { for(var i in this.handlers) { - this.handlers[i].setMap(map); + if (this.handlers.hasOwnProperty(i)) { + this.handlers[i].setMap(map); + } } OpenLayers.Control.prototype.setMap.apply(this, arguments); }, diff --git a/lib/OpenLayers/Control/NavigationHistory.js b/lib/OpenLayers/Control/NavigationHistory.js index eb46946e73..4fe47a629e 100644 --- a/lib/OpenLayers/Control/NavigationHistory.js +++ b/lib/OpenLayers/Control/NavigationHistory.js @@ -193,7 +193,9 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { this.next.destroy(); this.deactivate(); for(var prop in this) { - this[prop] = null; + if (this.hasOwnProperty(prop)) { + this[prop] = null; + } } }, @@ -334,25 +336,27 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { setListeners: function() { this.listeners = {}; for(var type in this.registry) { - this.listeners[type] = OpenLayers.Function.bind(function() { - if(!this.restoring) { - var state = this.registry[type].apply(this, arguments); - this.previousStack.unshift(state); - if(this.previousStack.length > 1) { - this.onPreviousChange( - this.previousStack[1], this.previousStack.length - 1 - ); + if (this.registry.hasOwnProperty(type)) { + this.listeners[type] = OpenLayers.Function.bind(function() { + if(!this.restoring) { + var state = this.registry[type].apply(this, arguments); + this.previousStack.unshift(state); + if(this.previousStack.length > 1) { + this.onPreviousChange( + this.previousStack[1], this.previousStack.length - 1 + ); + } + if(this.previousStack.length > (this.limit + 1)) { + this.previousStack.pop(); + } + if(this.nextStack.length > 0) { + this.nextStack = []; + this.onNextChange(null, 0); + } } - if(this.previousStack.length > (this.limit + 1)) { - this.previousStack.pop(); - } - if(this.nextStack.length > 0) { - this.nextStack = []; - this.onNextChange(null, 0); - } - } - return true; - }, this); + return true; + }, this); + } } }, @@ -371,7 +375,9 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { this.setListeners(); } for(var type in this.listeners) { - this.map.events.register(type, this, this.listeners[type]); + if (this.listeners.hasOwnProperty(type)) { + this.map.events.register(type, this, this.listeners[type]); + } } activated = true; if(this.previousStack.length == 0) { @@ -405,9 +411,11 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { if(this.map) { if(OpenLayers.Control.prototype.deactivate.apply(this)) { for(var type in this.listeners) { - this.map.events.unregister( - type, this, this.listeners[type] - ); + if (this.listeners.hasOwnProperty(type)) { + this.map.events.unregister( + type, this, this.listeners[type] + ); + } } if(this.clearOnDeactivate) { this.clear(); diff --git a/lib/OpenLayers/Control/SLDSelect.js b/lib/OpenLayers/Control/SLDSelect.js index 52f0798ae9..50ac906afd 100644 --- a/lib/OpenLayers/Control/SLDSelect.js +++ b/lib/OpenLayers/Control/SLDSelect.js @@ -168,11 +168,16 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, { * Take care of things that are not handled in superclass. */ destroy: function() { - for (var key in this.layerCache) { - delete this.layerCache[key]; + var key; + for (key in this.layerCache) { + if (this.layerCache.hasOwnProperty(key)) { + delete this.layerCache[key]; + } } - for (var key in this.wfsCache) { - delete this.wfsCache[key]; + for (key in this.wfsCache) { + if (this.wfsCache.hasOwnProperty(key)) { + delete this.wfsCache[key]; + } } OpenLayers.Control.prototype.destroy.apply(this, arguments); }, diff --git a/lib/OpenLayers/Control/WMSGetFeatureInfo.js b/lib/OpenLayers/Control/WMSGetFeatureInfo.js index 9348a9d542..67555f1038 100644 --- a/lib/OpenLayers/Control/WMSGetFeatureInfo.js +++ b/lib/OpenLayers/Control/WMSGetFeatureInfo.js @@ -456,10 +456,12 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { } var layers; for (var url in services) { - layers = services[url]; - var wmsOptions = this.buildWMSOptions(url, layers, - clickPosition, layers[0].params.FORMAT); - OpenLayers.Request.GET(wmsOptions); + if (services.hasOwnProperty(url)) { + layers = services[url]; + var wmsOptions = this.buildWMSOptions(url, layers, + clickPosition, layers[0].params.FORMAT); + OpenLayers.Request.GET(wmsOptions); + } } } }, diff --git a/lib/OpenLayers/Format/GML/Base.js b/lib/OpenLayers/Format/GML/Base.js index 0eceadaed6..9abbf5aa7a 100644 --- a/lib/OpenLayers/Format/GML/Base.js +++ b/lib/OpenLayers/Format/GML/Base.js @@ -564,12 +564,14 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, { this.writeNode("feature:_geometry", feature.geometry, node); } for(var name in feature.attributes) { - var value = feature.attributes[name]; - if(value != null) { - this.writeNode( - "feature:_attribute", - {name: name, value: value}, node - ); + if (feature.attributes.hasOwnProperty(name)) { + var value = feature.attributes[name]; + if(value != null) { + this.writeNode( + "feature:_attribute", + {name: name, value: value}, node + ); + } } } return node; diff --git a/lib/OpenLayers/Format/GeoRSS.js b/lib/OpenLayers/Format/GeoRSS.js index a9e117b2ec..0fc1790f6d 100644 --- a/lib/OpenLayers/Format/GeoRSS.js +++ b/lib/OpenLayers/Format/GeoRSS.js @@ -325,15 +325,17 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, { featureNode.appendChild(linkNode); } for(var attr in feature.attributes) { - if (attr == "link" || attr == "title" || attr == "description") { continue; } - var attrText = this.createTextNode(feature.attributes[attr]); - var nodename = attr; - if (attr.search(":") != -1) { - nodename = attr.split(":")[1]; - } - var attrContainer = this.createElementNS(this.featureNS, "feature:"+nodename); - attrContainer.appendChild(attrText); - featureNode.appendChild(attrContainer); + if (feature.attributes.hasOwnProperty(attr)) { + if (attr == "link" || attr == "title" || attr == "description") { continue; } + var attrText = this.createTextNode(feature.attributes[attr]); + var nodename = attr; + if (attr.search(":") != -1) { + nodename = attr.split(":")[1]; + } + var attrContainer = this.createElementNS(this.featureNS, "feature:"+nodename); + attrContainer.appendChild(attrText); + featureNode.appendChild(attrContainer); + } } featureNode.appendChild(geometryNode); return featureNode; diff --git a/lib/OpenLayers/Format/OSM.js b/lib/OpenLayers/Format/OSM.js index 48ef45ac91..a5de50fc35 100644 --- a/lib/OpenLayers/Format/OSM.js +++ b/lib/OpenLayers/Format/OSM.js @@ -140,33 +140,35 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, { feat_list[i] = feat; } for (var node_id in nodes) { - var node = nodes[node_id]; - if (!node.used || this.checkTags) { - var tags = null; + if (nodes.hasOwnProperty(node_id)) { + var node = nodes[node_id]; + if (!node.used || this.checkTags) { + var tags = null; - if (this.checkTags) { - var result = this.getTags(node.node, true); - if (node.used && !result[1]) { - continue; - } - tags = result[0]; - } else { - tags = this.getTags(node.node); - } + if (this.checkTags) { + var result = this.getTags(node.node, true); + if (node.used && !result[1]) { + continue; + } + tags = result[0]; + } else { + tags = this.getTags(node.node); + } - var feat = new OpenLayers.Feature.Vector( - new OpenLayers.Geometry.Point(node['lon'], node['lat']), - tags); - if (this.internalProjection && this.externalProjection) { - feat.geometry.transform(this.externalProjection, - this.internalProjection); - } - feat.osm_id = parseInt(node_id); - feat.fid = "node." + feat.osm_id; - feat_list.push(feat); - } - // Memory cleanup - node.node = null; + var feat = new OpenLayers.Feature.Vector( + new OpenLayers.Geometry.Point(node['lon'], node['lat']), + tags); + if (this.internalProjection && this.externalProjection) { + feat.geometry.transform(this.externalProjection, + this.internalProjection); + } + feat.osm_id = parseInt(node_id); + feat.fid = "node." + feat.osm_id; + feat_list.push(feat); + } + // Memory cleanup + node.node = null; + } } return feat_list; }, @@ -273,9 +275,11 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, { } if (this.checkTags) { for(var key in way.tags) { - if (this.areaTags[key]) { - poly_tags = true; - break; + if (way.tags.hasOwnProperty(key)) { + if (this.areaTags[key]) { + poly_tags = true; + break; + } } } } @@ -430,10 +434,12 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, { */ serializeTags: function(feature, node) { for (var key in feature.attributes) { - var tag = this.createElementNS(null, "tag"); - tag.setAttribute("k", key); - tag.setAttribute("v", feature.attributes[key]); - node.appendChild(tag); + if (feature.attributes.hasOwnProperty(key)) { + var tag = this.createElementNS(null, "tag"); + tag.setAttribute("k", key); + tag.setAttribute("v", feature.attributes[key]); + node.appendChild(tag); + } } }, diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index cd32810be9..2a1c2e33af 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -541,9 +541,11 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { getCssProperty: function(sym) { var css = null; for(var prop in this.cssMap) { - if(this.cssMap[prop] == sym) { - css = prop; - break; + if (this.cssMap.hasOwnProperty(prop)) { + if(this.cssMap[prop] == sym) { + css = prop; + break; + } } } return css; @@ -565,12 +567,14 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { getGraphicFormat: function(href) { var format, regex; for(var key in this.graphicFormats) { - if(this.graphicFormats[key].test(href)) { - format = key; - break; + if (this.graphicFormats.hasOwnProperty(key)) { + if(this.graphicFormats[key].test(href)) { + format = key; + break; + } } } - return format || this.defautlGraphicFormat; + return format || this.defaultGraphicFormat; }, /** @@ -676,7 +680,9 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { } } else { for(var name in sld.namedLayers) { - this.writeNode("NamedLayer", sld.namedLayers[name], root); + if (sld.namedLayers.hasOwnProperty(name)) { + this.writeNode("NamedLayer", sld.namedLayers[name], root); + } } } return root; @@ -769,11 +775,13 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { ruleMap[zIndex].symbolizers.push(symbolizer.clone()); } for (zIndex in ruleMap) { - if (!(zIndex in rulesByZ)) { - zValues.push(zIndex); - rulesByZ[zIndex] = []; + if (ruleMap.hasOwnProperty(zIndex)) { + if (!(zIndex in rulesByZ)) { + zValues.push(zIndex); + rulesByZ[zIndex] = []; + } + rulesByZ[zIndex].push(ruleMap[zIndex]); } - rulesByZ[zIndex].push(ruleMap[zIndex]); } } else { // no symbolizers in rule diff --git a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js index bee661311b..784e42b592 100644 --- a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js +++ b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js @@ -128,10 +128,12 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( var options = symbolizer.vendorOptions; if (options) { for (var key in symbolizer.vendorOptions) { - this.writeNode("VendorOption", { - name: key, - value: symbolizer.vendorOptions[key] - }, node); + if (symbolizer.vendorOptions.hasOwnProperty(key)) { + this.writeNode("VendorOption", { + name: key, + value: symbolizer.vendorOptions[key] + }, node); + } } } return node; diff --git a/lib/OpenLayers/Format/SOSGetObservation.js b/lib/OpenLayers/Format/SOSGetObservation.js index a7f2c1725f..feb1e35a49 100644 --- a/lib/OpenLayers/Format/SOSGetObservation.js +++ b/lib/OpenLayers/Format/SOSGetObservation.js @@ -210,10 +210,14 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, { this.writeNode("eventTime", options, node); } for (var procedure in options.procedures) { - this.writeNode("procedure", options.procedures[procedure], node); + if (options.procedures.hasOwnProperty(procedure)) { + this.writeNode("procedure", options.procedures[procedure], node); + } } for (var observedProperty in options.observedProperties) { - this.writeNode("observedProperty", options.observedProperties[observedProperty], node); + if (options.observedProperties.hasOwnProperty(observedProperty)) { + this.writeNode("observedProperty", options.observedProperties[observedProperty], node); + } } if (options.foi) { this.writeNode("featureOfInterest", options.foi, node); diff --git a/lib/OpenLayers/Format/WFS.js b/lib/OpenLayers/Format/WFS.js index 860df0aa5f..0d69566ad6 100644 --- a/lib/OpenLayers/Format/WFS.js +++ b/lib/OpenLayers/Format/WFS.js @@ -104,15 +104,17 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, { var featureContainer = this.createElementNS(this.featureNS, "feature:" + this.featureName); featureContainer.appendChild(geomContainer); for(var attr in feature.attributes) { - var attrText = this.createTextNode(feature.attributes[attr]); - var nodename = attr; - if (attr.search(":") != -1) { - nodename = attr.split(":")[1]; - } - var attrContainer = this.createElementNS(this.featureNS, "feature:" + nodename); - attrContainer.appendChild(attrText); - featureContainer.appendChild(attrContainer); - } + if (feature.attributes.hasOwnProperty(attr)) { + var attrText = this.createTextNode(feature.attributes[attr]); + var nodename = attr; + if (attr.search(":") != -1) { + nodename = attr.split(":")[1]; + } + var attrContainer = this.createElementNS(this.featureNS, "feature:" + nodename); + attrContainer.appendChild(attrText); + featureContainer.appendChild(attrContainer); + } + } return featureContainer; }, @@ -166,14 +168,16 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, { // add in attributes for(var propName in feature.attributes) { - propertyNode = this.createElementNS(this.wfsns, 'wfs:Property'); - nameNode = this.createElementNS(this.wfsns, 'wfs:Name'); - nameNode.appendChild(this.createTextNode(propName)); - propertyNode.appendChild(nameNode); - valueNode = this.createElementNS(this.wfsns, 'wfs:Value'); - valueNode.appendChild(this.createTextNode(feature.attributes[propName])); - propertyNode.appendChild(valueNode); - updateNode.appendChild(propertyNode); + if (feature.attributes.hasOwnProperty(propName)) { + propertyNode = this.createElementNS(this.wfsns, 'wfs:Property'); + nameNode = this.createElementNS(this.wfsns, 'wfs:Name'); + nameNode.appendChild(this.createTextNode(propName)); + propertyNode.appendChild(nameNode); + valueNode = this.createElementNS(this.wfsns, 'wfs:Value'); + valueNode.appendChild(this.createTextNode(feature.attributes[propName])); + propertyNode.appendChild(valueNode); + updateNode.appendChild(propertyNode); + } } diff --git a/lib/OpenLayers/Format/WFST/v1.js b/lib/OpenLayers/Format/WFST/v1.js index e3bf963afc..5341fd17a7 100644 --- a/lib/OpenLayers/Format/WFST/v1.js +++ b/lib/OpenLayers/Format/WFST/v1.js @@ -332,12 +332,14 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, { // add in attributes for(var key in feature.attributes) { - if(feature.attributes[key] !== undefined && - (!modified || !modified.attributes || - (modified.attributes && modified.attributes[key] !== undefined))) { - this.writeNode( - "Property", {name: key, value: feature.attributes[key]}, node - ); + if (feature.attributes.hasOwnProperty(key)) { + if(feature.attributes[key] !== undefined && + (!modified || !modified.attributes || + (modified.attributes && modified.attributes[key] !== undefined))) { + this.writeNode( + "Property", {name: key, value: feature.attributes[key]}, node + ); + } } } @@ -410,9 +412,11 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, { var parts = []; var uri; for(var key in schemaLocations) { - uri = this.namespaces[key]; - if(uri) { - parts.push(uri + " " + schemaLocations[key]); + if (schemaLocations.hasOwnProperty(key)) { + uri = this.namespaces[key]; + if(uri) { + parts.push(uri + " " + schemaLocations[key]); + } } } var value = parts.join(" ") || undefined; diff --git a/lib/OpenLayers/Format/WMC/v1.js b/lib/OpenLayers/Format/WMC/v1.js index e6eed09b44..46e1947cbc 100644 --- a/lib/OpenLayers/Format/WMC/v1.js +++ b/lib/OpenLayers/Format/WMC/v1.js @@ -48,8 +48,10 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { prefix = this.namespaces[this.defaultPrefix]; } else { for(prefix in this.namespaces) { - if(this.namespaces[prefix] == uri) { - break; + if (this.namespaces.hasOwnProperty(prefix)) { + if(this.namespaces[prefix] == uri) { + break; + } } } } @@ -674,12 +676,14 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { setAttributes: function(node, obj) { var value; for(var name in obj) { - value = obj[name].toString(); - if(value.match(/[A-Z]/)) { - // safari lowercases attributes with setAttribute - this.setAttributeNS(node, null, name, value); - } else { - node.setAttribute(name, value); + if (obj.hasOwnProperty(name)) { + value = obj[name].toString(); + if(value.match(/[A-Z]/)) { + // safari lowercases attributes with setAttribute + this.setAttributeNS(node, null, name, value); + } else { + node.setAttribute(name, value); + } } } }, @@ -1091,25 +1095,29 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { userValue: true }; for (var dim in context.dimensions) { - var attributes = {}; - var dimension = context.dimensions[dim]; - for (var name in dimension) { - if (typeof dimension[name] == "boolean") { - attributes[name] = Number(dimension[name]); - } else { - attributes[name] = dimension[name]; + if (context.dimensions.hasOwnProperty(dim)) { + var attributes = {}; + var dimension = context.dimensions[dim]; + for (var name in dimension) { + if (dimension.hasOwnProperty(name)) { + if (typeof dimension[name] == "boolean") { + attributes[name] = Number(dimension[name]); + } else { + attributes[name] = dimension[name]; + } + } + } + var values = ""; + if (attributes.values) { + values = attributes.values.join(","); + delete attributes.values; } - } - var values = ""; - if (attributes.values) { - values = attributes.values.join(","); - delete attributes.values; - } - node.appendChild(this.createElementDefaultNS( - "Dimension", values, attributes - )); - } + node.appendChild(this.createElementDefaultNS( + "Dimension", values, attributes + )); + } + } return node; }, diff --git a/lib/OpenLayers/Format/WMC/v1_1_0.js b/lib/OpenLayers/Format/WMC/v1_1_0.js index 16caf0ece4..ceed7f5fd2 100644 --- a/lib/OpenLayers/Format/WMC/v1_1_0.js +++ b/lib/OpenLayers/Format/WMC/v1_1_0.js @@ -122,7 +122,9 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class( // optional SRS element(s) if (context.srs) { for(var name in context.srs) { - node.appendChild(this.createElementDefaultNS("SRS", name)); + if (context.srs.hasOwnProperty(name)) { + node.appendChild(this.createElementDefaultNS("SRS", name)); + } } } diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index d69e944c5f..b142072092 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -84,8 +84,10 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers matrixSet: true }; for (var prop in required) { - if (!(prop in config)) { - throw new Error("Missing property '" + prop + "' in layer configuration."); + if (required.hasOwnProperty(prop)) { + if (!(prop in config)) { + throw new Error("Missing property '" + prop + "' in layer configuration."); + } } } diff --git a/lib/OpenLayers/Format/XML.js b/lib/OpenLayers/Format/XML.js index e5cc118891..3d8be16ed5 100644 --- a/lib/OpenLayers/Format/XML.js +++ b/lib/OpenLayers/Format/XML.js @@ -89,7 +89,9 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { this.namespaces = OpenLayers.Util.extend({}, this.namespaces); this.namespaceAlias = {}; for(var alias in this.namespaces) { - this.namespaceAlias[this.namespaces[alias]] = alias; + if (this.namespaces.hasOwnProperty(alias)) { + this.namespaceAlias[this.namespaces[alias]] = alias; + } } }, @@ -558,11 +560,13 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { setAttributes: function(node, obj) { var value, uri; for(var name in obj) { - if(obj[name] != null && obj[name].toString) { - value = obj[name].toString(); - // check for qualified attribute name ("prefix:local") - uri = this.namespaces[name.substring(0, name.indexOf(":"))] || null; - this.setAttributeNS(node, uri, name, value); + if (obj.hasOwnProperty(name)) { + if(obj[name] != null && obj[name].toString) { + value = obj[name].toString(); + // check for qualified attribute name ("prefix:local") + uri = this.namespaces[name.substring(0, name.indexOf(":"))] || null; + this.setAttributeNS(node, uri, name, value); + } } } }, diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 788b6e7633..76f6b5d6b7 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -423,7 +423,9 @@ OpenLayers.Layer = OpenLayers.Class({ getOptions: function() { var options = {}; for(var o in this.options) { - options[o] = this[o]; + if (this.options.hasOwnProperty(o)) { + options[o] = this[o]; + } } return options; }, diff --git a/lib/OpenLayers/Layer/HTTPRequest.js b/lib/OpenLayers/Layer/HTTPRequest.js index d1e9bf2219..6cbc83dc3d 100644 --- a/lib/OpenLayers/Layer/HTTPRequest.js +++ b/lib/OpenLayers/Layer/HTTPRequest.js @@ -218,8 +218,10 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, { var urlParams = OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(url)); for(var key in allParams) { - if(key.toUpperCase() in urlParams) { - delete allParams[key]; + if (allParams.hasOwnProperty(key)) { + if(key.toUpperCase() in urlParams) { + delete allParams[key]; + } } } paramsString = OpenLayers.Util.getParameterString(allParams); diff --git a/lib/OpenLayers/Layer/MapGuide.js b/lib/OpenLayers/Layer/MapGuide.js index 680b8472c2..4285fd6094 100644 --- a/lib/OpenLayers/Layer/MapGuide.js +++ b/lib/OpenLayers/Layer/MapGuide.js @@ -346,8 +346,10 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, { var urlParams = OpenLayers.Util.upperCaseObject( OpenLayers.Util.getParameters(url)); for(var key in allParams) { - if(key.toUpperCase() in urlParams) { - delete allParams[key]; + if (allParams.hasOwnProperty(key)) { + if(key.toUpperCase() in urlParams) { + delete allParams[key]; + } } } var paramsString = OpenLayers.Util.getParameterString(allParams); diff --git a/lib/OpenLayers/Layer/MapServer.js b/lib/OpenLayers/Layer/MapServer.js index 61e9930ab9..2151961713 100644 --- a/lib/OpenLayers/Layer/MapServer.js +++ b/lib/OpenLayers/Layer/MapServer.js @@ -142,8 +142,10 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, { var urlParams = OpenLayers.Util.upperCaseObject( OpenLayers.Util.getParameters(url)); for(var key in allParams) { - if(key.toUpperCase() in urlParams) { - delete allParams[key]; + if (allParams.hasOwnProperty(key)) { + if(key.toUpperCase() in urlParams) { + delete allParams[key]; + } } } paramsString = OpenLayers.Util.getParameterString(allParams); diff --git a/lib/OpenLayers/Layer/Vector.js b/lib/OpenLayers/Layer/Vector.js index 2857a82d7b..0e771b0017 100644 --- a/lib/OpenLayers/Layer/Vector.js +++ b/lib/OpenLayers/Layer/Vector.js @@ -509,8 +509,10 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, { if(!zoomChanged && coordSysUnchanged) { for(var i in this.unrenderedFeatures) { - var feature = this.unrenderedFeatures[i]; - this.drawFeature(feature); + if (this.unrenderedFeatures.hasOwnProperty(i)) { + var feature = this.unrenderedFeatures[i]; + this.drawFeature(feature); + } } } } @@ -1023,4 +1025,4 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, { }, CLASS_NAME: "OpenLayers.Layer.Vector" -}); \ No newline at end of file +}); diff --git a/lib/OpenLayers/Layer/WMTS.js b/lib/OpenLayers/Layer/WMTS.js index c82beb4d18..8673502f6f 100644 --- a/lib/OpenLayers/Layer/WMTS.js +++ b/lib/OpenLayers/Layer/WMTS.js @@ -229,8 +229,10 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, { matrixSet: true }; for (var prop in required) { - if (!(prop in config)) { - throw new Error("Missing property '" + prop + "' in layer configuration."); + if (required.hasOwnProperty(prop)) { + if (!(prop in config)) { + throw new Error("Missing property '" + prop + "' in layer configuration."); + } } } diff --git a/lib/OpenLayers/Protocol/Script.js b/lib/OpenLayers/Protocol/Script.js index 49e332b7f0..a92a0c9360 100644 --- a/lib/OpenLayers/Protocol/Script.js +++ b/lib/OpenLayers/Protocol/Script.js @@ -135,7 +135,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, { }); this.filterToParams = function(filter, params) { return format.write(filter, params); - } + }; } }, @@ -311,7 +311,9 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, { this.destroyRequest(response.priv); } else { for (var key in this.pendingRequests) { - this.destroyRequest(this.pendingRequests[key]); + if (this.pendingRequests.hasOwnProperty(key)) { + this.destroyRequest(this.pendingRequests[key]); + } } } }, diff --git a/lib/OpenLayers/Request.js b/lib/OpenLayers/Request.js index a5de46fdee..f1f51467a2 100644 --- a/lib/OpenLayers/Request.js +++ b/lib/OpenLayers/Request.js @@ -181,7 +181,9 @@ OpenLayers.Request = { config.method, url, config.async, config.user, config.password ); for(var header in config.headers) { - request.setRequestHeader(header, config.headers[header]); + if (config.headers.hasOwnProperty(header)) { + request.setRequestHeader(header, config.headers[header]); + } } var events = this.events; diff --git a/lib/OpenLayers/Rule.js b/lib/OpenLayers/Rule.js index 452b3de25f..0f7db50ae2 100644 --- a/lib/OpenLayers/Rule.js +++ b/lib/OpenLayers/Rule.js @@ -128,7 +128,9 @@ OpenLayers.Rule = OpenLayers.Class({ */ destroy: function() { for (var i in this.symbolizer) { - this.symbolizer[i] = null; + if (this.symbolizer.hasOwnProperty(i)) { + this.symbolizer[i] = null; + } } this.symbolizer = null; delete this.symbolizers; @@ -216,12 +218,14 @@ OpenLayers.Rule = OpenLayers.Class({ options.symbolizer = {}; var value, type; for(var key in this.symbolizer) { - value = this.symbolizer[key]; - type = typeof value; - if(type === "object") { - options.symbolizer[key] = OpenLayers.Util.extend({}, value); - } else if(type === "string") { - options.symbolizer[key] = value; + if (this.symbolizer.hasOwnProperty(key)) { + value = this.symbolizer[key]; + type = typeof value; + if(type === "object") { + options.symbolizer[key] = OpenLayers.Util.extend({}, value); + } else if(type === "string") { + options.symbolizer[key] = value; + } } } } @@ -233,4 +237,4 @@ OpenLayers.Rule = OpenLayers.Class({ }, CLASS_NAME: "OpenLayers.Rule" -}); \ No newline at end of file +}); diff --git a/lib/OpenLayers/Style.js b/lib/OpenLayers/Style.js index 1af88dfba2..891af83181 100644 --- a/lib/OpenLayers/Style.js +++ b/lib/OpenLayers/Style.js @@ -273,7 +273,9 @@ OpenLayers.Style = OpenLayers.Class({ OpenLayers.Util.extend(context, this.context); for (var i in this.propertyStyles) { - style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i); + if (this.propertyStyles.hasOwnProperty(i)) { + style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i); + } } return style; }, @@ -301,14 +303,16 @@ OpenLayers.Style = OpenLayers.Class({ for (var i=0, len=rules.length; i