Skip to content

Commit

Permalink
Ignore children of void elements when serializing
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeroman committed Jan 10, 2019
1 parent d8b025c commit f7db574
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 406 deletions.
10 changes: 4 additions & 6 deletions components/script/dom/servoparser/html.rs
Expand Up @@ -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(),
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f7db574

Please sign in to comment.