Add new XMLSerializer().serializeToString functionality

This commit is contained in:
Felipe Janer 2019-04-01 18:39:48 -05:00
parent 9832feddf3
commit 1ffe8f059a
4 changed files with 10 additions and 2 deletions

View file

@ -167,7 +167,7 @@ fn rev_children_iter(n: &Node) -> impl Iterator<Item = DomRoot<Node>> {
impl SerializationIterator { impl SerializationIterator {
fn new(node: &Node, skip_first: bool) -> SerializationIterator { fn new(node: &Node, skip_first: bool) -> SerializationIterator {
let mut ret = SerializationIterator { stack: vec![] }; let mut ret = SerializationIterator { stack: vec![] };
if skip_first || node.is::<DocumentFragment>() { if skip_first || node.is::<DocumentFragment>() || node.is::<Document>() {
for c in rev_children_iter(node) { for c in rev_children_iter(node) {
ret.push_node(&*c); ret.push_node(&*c);
} }

View file

@ -642622,7 +642622,7 @@
"support" "support"
], ],
"domparsing/XMLSerializer-serializeToString.html": [ "domparsing/XMLSerializer-serializeToString.html": [
"23b9ce841f5046f180ce78d92d7ac1132712f999", "1ee9b8014c5d0983a02722a0db8caa83df958439",
"testharness" "testharness"
], ],
"domparsing/createContextualFragment.html": [ "domparsing/createContextualFragment.html": [

View file

@ -1,5 +1,8 @@
[XMLSerializer-serializeToString.html] [XMLSerializer-serializeToString.html]
type: testharness type: testharness
[check XMLSerializer.serializeToString method could parsing document to string]
expected: FAIL
[Check if the default namespace is correctly reset.] [Check if the default namespace is correctly reset.]
expected: FAIL expected: FAIL

View file

@ -31,6 +31,11 @@ test(function() {
assert_equals(serialize(root), '<root><child1>value1</child1></root>'); assert_equals(serialize(root), '<root><child1>value1</child1></root>');
}, 'check XMLSerializer.serializeToString method could parsing xmldoc to string'); }, 'check XMLSerializer.serializeToString method could parsing xmldoc to string');
test(function() {
var root = parse('<html><head></head><body><div></div><span></span></body></html>');
assert_equals(serialize(root.ownerDocument), '<html><head/><body><div/><span/></body></html>');
}, 'check XMLSerializer.serializeToString method could parsing document to string');
test(function() { test(function() {
var root = createXmlDoc().documentElement; var root = createXmlDoc().documentElement;
var element = root.ownerDocument.createElementNS('urn:foo', 'another'); var element = root.ownerDocument.createElementNS('urn:foo', 'another');