Fix a localization problem with the XML format's createTextNode method in IE, p=fvanderbiest,me r=fredj (closes #2782)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10676 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -243,6 +243,9 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
|
|||||||
*/
|
*/
|
||||||
createTextNode: function(text) {
|
createTextNode: function(text) {
|
||||||
var node;
|
var node;
|
||||||
|
if (typeof text !== "string") {
|
||||||
|
text = String(text);
|
||||||
|
}
|
||||||
if(this.xmldom) {
|
if(this.xmldom) {
|
||||||
node = this.xmldom.createTextNode(text);
|
node = this.xmldom.createTextNode(text);
|
||||||
} else {
|
} else {
|
||||||
@@ -568,9 +571,6 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
|
|||||||
}
|
}
|
||||||
var value = options.value;
|
var value = options.value;
|
||||||
if(value != null) {
|
if(value != null) {
|
||||||
if(typeof value == "boolean") {
|
|
||||||
value = String(value);
|
|
||||||
}
|
|
||||||
node.appendChild(this.createTextNode(value));
|
node.appendChild(this.createTextNode(value));
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
|
|||||||
+31
-7
@@ -167,18 +167,38 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_Format_XML_createTextNode(t) {
|
function test_Format_XML_createTextNode(t) {
|
||||||
t.plan(4);
|
t.plan(10);
|
||||||
|
|
||||||
var format = new OpenLayers.Format.XML();
|
var format = new OpenLayers.Format.XML();
|
||||||
var value = Math.random().toString();
|
var value, node;
|
||||||
var node = format.createTextNode(value);
|
|
||||||
|
value = "string";
|
||||||
|
node = format.createTextNode(value);
|
||||||
t.eq(node.nodeType, 3,
|
t.eq(node.nodeType, 3,
|
||||||
"node has correct type");
|
"[string] node has correct type");
|
||||||
t.eq(node.nodeName, "#text",
|
t.eq(node.nodeName, "#text",
|
||||||
"node has correct name");
|
"[string] node has correct name");
|
||||||
t.eq(node.nodeValue, value,
|
t.eq(node.nodeValue, "string",
|
||||||
"node has correct value");
|
"[string] node has correct value");
|
||||||
|
|
||||||
|
value = 0.42;
|
||||||
|
node = format.createTextNode(value);
|
||||||
|
t.eq(node.nodeType, 3,
|
||||||
|
"[number] node has correct type");
|
||||||
|
t.eq(node.nodeName, "#text",
|
||||||
|
"[number] node has correct name");
|
||||||
|
t.eq(node.nodeValue, "0.42",
|
||||||
|
"[number] node has correct value");
|
||||||
|
|
||||||
|
value = false;
|
||||||
|
node = format.createTextNode(value);
|
||||||
|
t.eq(node.nodeType, 3,
|
||||||
|
"[boolean] node has correct type");
|
||||||
|
t.eq(node.nodeName, "#text",
|
||||||
|
"[boolean] node has correct name");
|
||||||
|
t.eq(node.nodeValue, "false",
|
||||||
|
"[boolean] node has correct value");
|
||||||
|
|
||||||
var doc = format.read(text);
|
var doc = format.read(text);
|
||||||
if (doc.importNode) {
|
if (doc.importNode) {
|
||||||
node = doc.importNode(node, true);
|
node = doc.importNode(node, true);
|
||||||
@@ -595,6 +615,10 @@
|
|||||||
description: "value of 0 gets appended as a text node",
|
description: "value of 0 gets appended as a text node",
|
||||||
node: format.createElementNSPlus("foo:bar", {value: 0}),
|
node: format.createElementNSPlus("foo:bar", {value: 0}),
|
||||||
expect: "<foo:bar xmlns:foo='http://example.com/foo'>0</foo:bar>"
|
expect: "<foo:bar xmlns:foo='http://example.com/foo'>0</foo:bar>"
|
||||||
|
}, {
|
||||||
|
description: "value of 0.42 gets appended as a text node",
|
||||||
|
node: format.createElementNSPlus("foo:bar", {value: 0.42}),
|
||||||
|
expect: "<foo:bar xmlns:foo='http://example.com/foo'>0.42</foo:bar>"
|
||||||
}, {
|
}, {
|
||||||
description: "value of true gets appended as a text node",
|
description: "value of true gets appended as a text node",
|
||||||
node: format.createElementNSPlus("foo:bar", {value: true}),
|
node: format.createElementNSPlus("foo:bar", {value: true}),
|
||||||
|
|||||||
Reference in New Issue
Block a user