diff options
-rw-r--r-- | src/components/script/dom/document.rs | 10 |
1 files 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<Window>, - pub idmap: HashMap<DOMString, ~[JS<Element>]>, + pub idmap: HashMap<DOMString, Vec<JS<Element>>>, pub implementation: Option<JS<DOMImplementation>>, 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<JS<Element>> { - // 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())); } } |