auto merge of #3577 : ttaubert/servo/issue/3193-named-element-mangle, r=jdm

Should probably use HashMap::entry() but that doesn't seem to be available with servo's current rust snapshot.

r? @Ms2ger
This commit is contained in:
bors-servo 2014-10-08 13:15:32 -06:00
commit a127fcd854

View file

@ -241,11 +241,9 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
let mut idmap = self.idmap.borrow_mut(); let mut idmap = self.idmap.borrow_mut();
// FIXME https://github.com/mozilla/rust/issues/13195
// Use mangle() when it exists again.
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root(); let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
match idmap.find_mut(&id) { idmap.find_with_or_insert_with(id, element,
Some(elements) => { |_key, elements, element| {
let new_node: JSRef<Node> = NodeCast::from_ref(element); let new_node: JSRef<Node> = NodeCast::from_ref(element);
let mut head : uint = 0u; let mut head : uint = 0u;
let root: JSRef<Node> = NodeCast::from_ref(*root); let root: JSRef<Node> = NodeCast::from_ref(*root);
@ -264,13 +262,9 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
} }
} }
elements.insert_unrooted(head, &element); elements.insert_unrooted(head, &element);
return;
}, },
None => (), |_key, element| vec![element.unrooted()]
} );
let mut elements = vec!();
elements.push_unrooted(&element);
idmap.insert(id, elements);
} }
fn load_anchor_href(self, href: DOMString) { fn load_anchor_href(self, href: DOMString) {