Revert "protect for in loops with hasOwnProperty"

This reverts commit e3cc96dbfb.
This commit is contained in:
Éric Lemoine
2012-03-03 22:35:39 +01:00
parent 161b54b6f1
commit 9a116b21b9
31 changed files with 267 additions and 386 deletions
+6 -8
View File
@@ -564,14 +564,12 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
this.writeNode("feature:_geometry", feature.geometry, node);
}
for(var name in feature.attributes) {
if (feature.attributes.hasOwnProperty(name)) {
var value = feature.attributes[name];
if(value != null) {
this.writeNode(
"feature:_attribute",
{name: name, value: value}, node
);
}
var value = feature.attributes[name];
if(value != null) {
this.writeNode(
"feature:_attribute",
{name: name, value: value}, node
);
}
}
return node;
+9 -11
View File
@@ -325,17 +325,15 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
featureNode.appendChild(linkNode);
}
for(var attr in feature.attributes) {
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);
}
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;
+32 -38
View File
@@ -140,35 +140,33 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
feat_list[i] = feat;
}
for (var node_id in nodes) {
if (nodes.hasOwnProperty(node_id)) {
var node = nodes[node_id];
if (!node.used || this.checkTags) {
var tags = null;
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;
},
@@ -275,11 +273,9 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
}
if (this.checkTags) {
for(var key in way.tags) {
if (way.tags.hasOwnProperty(key)) {
if (this.areaTags[key]) {
poly_tags = true;
break;
}
if (this.areaTags[key]) {
poly_tags = true;
break;
}
}
}
@@ -434,12 +430,10 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
*/
serializeTags: function(feature, node) {
for (var key in feature.attributes) {
if (feature.attributes.hasOwnProperty(key)) {
var tag = this.createElementNS(null, "tag");
tag.setAttribute("k", key);
tag.setAttribute("v", feature.attributes[key]);
node.appendChild(tag);
}
var tag = this.createElementNS(null, "tag");
tag.setAttribute("k", key);
tag.setAttribute("v", feature.attributes[key]);
node.appendChild(tag);
}
},
+12 -20
View File
@@ -541,11 +541,9 @@ 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.hasOwnProperty(prop)) {
if(this.cssMap[prop] == sym) {
css = prop;
break;
}
if(this.cssMap[prop] == sym) {
css = prop;
break;
}
}
return css;
@@ -567,14 +565,12 @@ 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.hasOwnProperty(key)) {
if(this.graphicFormats[key].test(href)) {
format = key;
break;
}
if(this.graphicFormats[key].test(href)) {
format = key;
break;
}
}
return format || this.defaultGraphicFormat;
return format || this.defautlGraphicFormat;
},
/**
@@ -680,9 +676,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
}
} else {
for(var name in sld.namedLayers) {
if (sld.namedLayers.hasOwnProperty(name)) {
this.writeNode("NamedLayer", sld.namedLayers[name], root);
}
this.writeNode("NamedLayer", sld.namedLayers[name], root);
}
}
return root;
@@ -775,13 +769,11 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
ruleMap[zIndex].symbolizers.push(symbolizer.clone());
}
for (zIndex in ruleMap) {
if (ruleMap.hasOwnProperty(zIndex)) {
if (!(zIndex in rulesByZ)) {
zValues.push(zIndex);
rulesByZ[zIndex] = [];
}
rulesByZ[zIndex].push(ruleMap[zIndex]);
if (!(zIndex in rulesByZ)) {
zValues.push(zIndex);
rulesByZ[zIndex] = [];
}
rulesByZ[zIndex].push(ruleMap[zIndex]);
}
} else {
// no symbolizers in rule
@@ -128,12 +128,10 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class(
var options = symbolizer.vendorOptions;
if (options) {
for (var key in symbolizer.vendorOptions) {
if (symbolizer.vendorOptions.hasOwnProperty(key)) {
this.writeNode("VendorOption", {
name: key,
value: symbolizer.vendorOptions[key]
}, node);
}
this.writeNode("VendorOption", {
name: key,
value: symbolizer.vendorOptions[key]
}, node);
}
}
return node;
+2 -6
View File
@@ -210,14 +210,10 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
this.writeNode("eventTime", options, node);
}
for (var procedure in options.procedures) {
if (options.procedures.hasOwnProperty(procedure)) {
this.writeNode("procedure", options.procedures[procedure], node);
}
this.writeNode("procedure", options.procedures[procedure], node);
}
for (var observedProperty in options.observedProperties) {
if (options.observedProperties.hasOwnProperty(observedProperty)) {
this.writeNode("observedProperty", options.observedProperties[observedProperty], node);
}
this.writeNode("observedProperty", options.observedProperties[observedProperty], node);
}
if (options.foi) {
this.writeNode("featureOfInterest", options.foi, node);
+17 -21
View File
@@ -104,17 +104,15 @@ 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) {
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);
}
}
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;
},
@@ -168,16 +166,14 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, {
// add in attributes
for(var propName in feature.attributes) {
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);
}
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);
}
+9 -13
View File
@@ -332,14 +332,12 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
// add in attributes
for(var key in feature.attributes) {
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
);
}
if(feature.attributes[key] !== undefined &&
(!modified || !modified.attributes ||
(modified.attributes && modified.attributes[key] !== undefined))) {
this.writeNode(
"Property", {name: key, value: feature.attributes[key]}, node
);
}
}
@@ -412,11 +410,9 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
var parts = [];
var uri;
for(var key in schemaLocations) {
if (schemaLocations.hasOwnProperty(key)) {
uri = this.namespaces[key];
if(uri) {
parts.push(uri + " " + schemaLocations[key]);
}
uri = this.namespaces[key];
if(uri) {
parts.push(uri + " " + schemaLocations[key]);
}
}
var value = parts.join(" ") || undefined;
+25 -33
View File
@@ -48,10 +48,8 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
prefix = this.namespaces[this.defaultPrefix];
} else {
for(prefix in this.namespaces) {
if (this.namespaces.hasOwnProperty(prefix)) {
if(this.namespaces[prefix] == uri) {
break;
}
if(this.namespaces[prefix] == uri) {
break;
}
}
}
@@ -676,14 +674,12 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
setAttributes: function(node, obj) {
var value;
for(var name in obj) {
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);
}
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);
}
}
},
@@ -1095,29 +1091,25 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
userValue: true
};
for (var dim in context.dimensions) {
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 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];
}
}
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;
},
+1 -3
View File
@@ -122,9 +122,7 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class(
// optional SRS element(s)
if (context.srs) {
for(var name in context.srs) {
if (context.srs.hasOwnProperty(name)) {
node.appendChild(this.createElementDefaultNS("SRS", name));
}
node.appendChild(this.createElementDefaultNS("SRS", name));
}
}
+2 -4
View File
@@ -84,10 +84,8 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
matrixSet: true
};
for (var prop in required) {
if (required.hasOwnProperty(prop)) {
if (!(prop in config)) {
throw new Error("Missing property '" + prop + "' in layer configuration.");
}
if (!(prop in config)) {
throw new Error("Missing property '" + prop + "' in layer configuration.");
}
}
+6 -10
View File
@@ -89,9 +89,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
this.namespaces = OpenLayers.Util.extend({}, this.namespaces);
this.namespaceAlias = {};
for(var alias in this.namespaces) {
if (this.namespaces.hasOwnProperty(alias)) {
this.namespaceAlias[this.namespaces[alias]] = alias;
}
this.namespaceAlias[this.namespaces[alias]] = alias;
}
},
@@ -560,13 +558,11 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
setAttributes: function(node, obj) {
var value, uri;
for(var name in obj) {
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);
}
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);
}
}
},