Auto merge of #23153 - 5h1rU:xmlserializer-serializetostring-panics, r=jdm

Make serializeToString serialize document nodes correctly

<!-- Please describe your changes on the following line: -->
This is the fix for ScriptThread panic when `new XMLSerializer().serializeToString(document);` is called.

r?@jdm

---
<!-- 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 #23130

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- 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/23153)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-04-15 23:30:56 -04:00 committed by GitHub
commit 456ea6a388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 {
fn new(node: &Node, skip_first: bool) -> SerializationIterator {
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) {
ret.push_node(&*c);
}