From 734699298153e7da6c4f738980aa05bcdc77dc2d Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 26 Apr 2014 10:37:27 +0200 Subject: [PATCH] Make Document::idmap store a Vec. --- src/components/script/dom/document.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 4e953a42629..9f5b9ed15d9 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -58,7 +58,7 @@ pub struct Document { pub node: Node, pub reflector_: Reflector, pub window: JS, - pub idmap: HashMap]>, + pub idmap: HashMap>>, pub implementation: Option>, pub content_type: DOMString, pub encoding_name: DOMString, @@ -232,11 +232,9 @@ impl Document { // http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid pub fn GetElementById(&self, id: DOMString) -> Option> { - // TODO: "in tree order, within the context object's tree" - // http://dom.spec.whatwg.org/#dom-document-getelementbyid. match self.idmap.find_equiv(&id) { None => None, - Some(ref elements) => Some(elements[0].clone()), + Some(ref elements) => Some(elements.get(0).clone()), } } @@ -679,7 +677,7 @@ impl Document { for node in root.traverse_preorder() { match ElementCast::to(&node) { Some(elem) => { - if elements[head] == elem { + if elements.get(head) == &elem { head = head + 1; } if new_node == node || head == elements.len() { @@ -694,6 +692,6 @@ impl Document { }, None => (), } - self.idmap.insert(id, ~[element.clone()]); + self.idmap.insert(id, vec!(element.clone())); } }