diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-01-10 10:28:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-10 10:28:13 -0500 |
commit | 160842b8c15ef328ec380f9f69403d88372bafde (patch) | |
tree | ecad54eb8ae3ba9d5b205bdf55958bdabd9e96f2 /components/script/dom | |
parent | 4ac5b8a3aea5df3bf374dcfdb22c34f5ff0bafe8 (diff) | |
parent | f7db5743f4f508f611fbdb7e8aa5fb99b41dd30a (diff) | |
download | servo-160842b8c15ef328ec380f9f69403d88372bafde.tar.gz servo-160842b8c15ef328ec380f9f69403d88372bafde.zip |
Auto merge of #22669 - georgeroman:ignore_children_of_void_when_serializing, r=jdm
Ignore children of void elements when serializing
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #22607
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22669)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/servoparser/html.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs index 62fe26153ed..45ef625a5ee 100644 --- a/components/script/dom/servoparser/html.rs +++ b/components/script/dom/servoparser/html.rs @@ -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 { |