Skip to content

Commit

Permalink
Auto merge of #8403 - frewsxcv:node-from-nodes-and-strings, r=nox
Browse files Browse the repository at this point in the history
Minor 'node_from_nodes_and_strings' cleanup

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8403)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Nov 8, 2015
2 parents 92f9e58 + 9443b89 commit fc98b8e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions components/script/dom/document.rs
Expand Up @@ -930,15 +930,14 @@ impl Document {
ReflowReason::KeyEvent);
}

pub fn node_from_nodes_and_strings(&self, nodes: Vec<NodeOrString>)
// https://dom.spec.whatwg.org/#converting-nodes-into-a-node
pub fn node_from_nodes_and_strings(&self, mut nodes: Vec<NodeOrString>)
-> Fallible<Root<Node>> {
if nodes.len() == 1 {
match nodes.into_iter().next().unwrap() {
NodeOrString::eNode(node) => Ok(node),
NodeOrString::eString(string) => {
Ok(Root::upcast(self.CreateTextNode(string)))
},
}
Ok(match nodes.pop().unwrap() {
NodeOrString::eNode(node) => node,
NodeOrString::eString(string) => Root::upcast(self.CreateTextNode(string)),
})
} else {
let fragment = Root::upcast::<Node>(self.CreateDocumentFragment());
for node in nodes {
Expand Down

0 comments on commit fc98b8e

Please sign in to comment.