XML Serialization doesn't wrap nodes in documents. This breaks or changes

serialization in some browsers. This fixes the XML Format based
tests in Safari. (Closes #1218)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@5487 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-12-18 12:17:34 +00:00
parent 93d73acd49
commit d4ff6a4c8b

View File

@@ -110,7 +110,15 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
data = node.xml;
} else {
var serializer = new XMLSerializer();
data = serializer.serializeToString(node);
if (node.nodeType == 1) {
// Add nodes to a document before serializing. Everything else
// is serialized as is. This may need more work. See #1218 .
var doc = document.implementation.createDocument("", "", null);
doc.appendChild(node);
data = serializer.serializeToString(doc);
} else {
data = serializer.serializeToString(node);
}
}
return data;
},