mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #8403 - frewsxcv:node-from-nodes-and-strings, r=nox
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 -->
This commit is contained in:
commit
fc98b8e126
1 changed files with 6 additions and 7 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue