Merge pull request #733 from tschaub/filter-tweaks

Allow writer functions to use document fragments when they need to append more than a single child to the parent.
This commit is contained in:
Tim Schaub
2012-10-26 09:45:53 -07:00
3 changed files with 59 additions and 33 deletions
+29
View File
@@ -166,6 +166,35 @@
"node can be appended to a doc root");
}
function test_createDocumentFragment(t) {
t.plan(3);
var format = new OpenLayers.Format.XML();
var uri = "http://foo.com";
var prefix = "foo";
var localName = "bar";
var qualifiedName = prefix + ":" + localName;
var parent = format.createElementNS(uri, qualifiedName);
var fragment = format.createDocumentFragment();
t.eq(fragment.nodeType, 11, "fragment type");
try {
fragment.appendChild(format.createTextNode("one"));
fragment.appendChild(format.createTextNode("two"));
t.eq(fragment.childNodes.length, 2, "fragment has two child nodes");
} catch (err) {
t.fail("trouble appending text nodes to fragment: " + err.message);
}
try {
parent.appendChild(fragment);
t.eq(parent.childNodes.length, 2, "parent has two child nodes");
} catch (err) {
t.fail("trouble appending fragment to parent: " + err.message);
}
}
function test_Format_XML_createTextNode(t) {
t.plan(10);