The createElementNSPlus method should append non-null values to the newly created node. Thanks for the quick review. r=crschmidt (closes #1883)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@8545 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -493,7 +493,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
|
||||
if(options.attributes) {
|
||||
this.setAttributes(node, options.attributes);
|
||||
}
|
||||
if(options.value) {
|
||||
if(options.value != null) {
|
||||
node.appendChild(this.createTextNode(options.value));
|
||||
}
|
||||
return node;
|
||||
|
||||
@@ -591,6 +591,22 @@
|
||||
value: "text value"
|
||||
}),
|
||||
expect: "<foo:FooNode xmlns:foo='http://example.com/foo' id='123'>text value<" + "/foo:FooNode>"
|
||||
}, {
|
||||
description: "value of 0 gets appended as a text node",
|
||||
node: format.createElementNSPlus("foo:bar", {value: 0}),
|
||||
expect: "<foo:bar xmlns:foo='http://example.com/foo'>0</foo:bar>"
|
||||
}, {
|
||||
description: "value of false gets appended as a text node",
|
||||
node: format.createElementNSPlus("foo:bar", {value: false}),
|
||||
expect: "<foo:bar xmlns:foo='http://example.com/foo'>false</foo:bar>"
|
||||
}, {
|
||||
description: "null value does not get appended as a text node",
|
||||
node: format.createElementNSPlus("foo:bar", {value: null}),
|
||||
expect: "<foo:bar xmlns:foo='http://example.com/foo'/>"
|
||||
}, {
|
||||
description: "undefined value does not get appended as a text node",
|
||||
node: format.createElementNSPlus("foo:bar"),
|
||||
expect: "<foo:bar xmlns:foo='http://example.com/foo'/>"
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user