diff options
-rw-r--r-- | components/script/dom/document.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index e47b7f36186..dc3225bba04 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -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 { |