[OpenLayers-Commits] r12188 - in trunk/openlayers:
lib/OpenLayers/Format/WFST tests/Format/WFST
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Jul 25 10:01:01 EDT 2011
Author: bartvde
Date: 2011-07-25 07:01:00 -0700 (Mon, 25 Jul 2011)
New Revision: 12188
Modified:
trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js
trunk/openlayers/tests/Format/WFST/v1.html
Log:
modified checks for Format.WFST should use not equal to undefined instead of truthy to deal properly with initial null values, r=ahocevar (closes #3436)
Modified: trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js 2011-07-25 13:13:46 UTC (rev 12187)
+++ trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js 2011-07-25 14:01:00 UTC (rev 12188)
@@ -183,12 +183,12 @@
* transaction:
* - *modified* is not set at all: The geometry and all attributes will be
* included.
- * - *modified.geometry* is truthy: The geometry will be
+ * - *modified.geometry* is set (null or a geometry): The geometry will be
* included. If *modified.attributes* is not set, all attributes will
* be included.
- * - *modified.attributes* is set: Only the attributes with a truthy value
- * in *modified.attributes* will be included. If *modified.geometry*
- * is not set, the geometry will not be included.
+ * - *modified.attributes* is set: Only the attributes set (i.e. to null or
+ * a value) in *modified.attributes* will be included.
+ * If *modified.geometry* is not set, the geometry will not be included.
*
* Valid options include:
* - *multi* {Boolean} If set to true, geometries will be casted to
@@ -323,7 +323,7 @@
// add in geometry
var modified = feature.modified;
- if (this.geometryName !== null && (!modified || modified.geometry)) {
+ if (this.geometryName !== null && (!modified || modified.geometry !== undefined)) {
this.srsName = this.getSrsName(feature);
this.writeNode(
"Property", {name: this.geometryName, value: feature.geometry}, node
@@ -334,7 +334,7 @@
for(var key in feature.attributes) {
if(feature.attributes[key] !== undefined &&
(!modified || !modified.attributes ||
- (modified.attributes && modified.attributes[key]))) {
+ (modified.attributes && modified.attributes[key] !== undefined))) {
this.writeNode(
"Property", {name: key, value: feature.attributes[key]}, node
);
Modified: trunk/openlayers/tests/Format/WFST/v1.html
===================================================================
--- trunk/openlayers/tests/Format/WFST/v1.html 2011-07-25 13:13:46 UTC (rev 12187)
+++ trunk/openlayers/tests/Format/WFST/v1.html 2011-07-25 14:01:00 UTC (rev 12188)
@@ -45,7 +45,7 @@
deleteFeature.state = OpenLayers.State.DELETE;
deleteFeature.fid = "fid.37";
- t.plan(7);
+ t.plan(8);
var snippets = {
"GetFeature": {handle: "handle_g", maxFeatures: 1, outputFormat: 'json'},
"Transaction": {handle: "handle_t"},
@@ -74,6 +74,14 @@
var expected = readXML("UpdateModifiedNoGeometry");
var got = format.writers["wfs"]["Update"].apply(format, [{feature: updateFeature}]);
t.xml_eq(got, expected, "Update request for feature with no modified geometry but modified attributes created correctly");
+
+ // test for a feature that originally had a null geometry and a null value for the attribute
+ updateFeature.modified = {attributes: {foo: null, nul: "nul"}, geometry: null};
+ updateFeature.attributes.foo = "bar";
+ updateFeature.geometry = new OpenLayers.Geometry.Point(2,3);
+ var expected = readXML("UpdateModified");
+ var got = format.writers["wfs"]["Update"].apply(format, [{feature: updateFeature}]);
+ t.xml_eq(got, expected, "Update request for feature with modified geometry created correctly even if original geometry was null");
}
function test_writeNative(t) {
More information about the Commits
mailing list