Permalink
Browse files

Ignore children of void elements when serializing

  • Loading branch information...
georgeroman committed Jan 10, 2019
1 parent d8b025c commit f7db5743f4f508f611fbdb7e8aa5fb99b41dd30a
@@ -153,6 +153,10 @@ struct SerializationIterator {
}

fn rev_children_iter(n: &Node) -> impl Iterator<Item = DomRoot<Node>> {
if n.downcast::<Element>().map_or(false, |e| e.is_void()) {
return Node::new_document_node().rev_children();
}

match n.downcast::<HTMLTemplateElement>() {
Some(t) => t.Content().upcast::<Node>().rev_children(),
None => n.rev_children(),
@@ -210,12 +214,6 @@ impl<'a> Serialize for &'a Node {
) -> io::Result<()> {
let node = *self;

if let TraversalScope::ChildrenOnly(_) = traversal_scope {
if node.downcast::<Element>().map_or(false, |e| e.is_void()) {
return Ok(());
}
}

let iter = SerializationIterator::new(node, traversal_scope != IncludeNode);

for cmd in iter {
Oops, something went wrong.

0 comments on commit f7db574

Please sign in to comment.