diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index b699f63f50f..3f917023c88 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -504,35 +504,4 @@ impl Document { *old_element = new_element.clone(); }); } - - pub fn update_idmap(&mut self, - abstract_self: &JS, - new_id: Option, - old_id: Option) { - // remove old ids: - // * if the old ones are not same as the new one, - // * OR if the new one is none. - match old_id { - Some(ref old_id) if new_id.is_none() || - (*new_id.get_ref() != *old_id) => { - self.idmap.remove(old_id); - } - _ => () - } - - match new_id { - Some(new_id) => { - // TODO: support the case if multiple elements - // which haves same id are in the same document. - self.idmap.mangle(new_id, abstract_self.clone(), - |_, new_node: JS| -> JS { - new_node - }, - |_, old_node: &mut JS, new_node: JS| { - *old_node = new_node; - }); - } - None => () - } - } } diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index d0bc904afe6..b3d5d06f38a 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -207,10 +207,14 @@ impl Element { let idx = self.attrs.iter().position(|attr| { attr.get().local_name == local_name }); - let old_raw_value = idx.map(|idx| self.attrs[idx].get().Value()); match idx { Some(idx) => { + if namespace == namespace::Null { + let old_value = self.attrs[idx].get().Value(); + self.before_remove_attr(abstract_self, local_name.clone(), + old_value); + } self.attrs[idx].get_mut().set_value(value.clone()); } None => { @@ -224,7 +228,7 @@ impl Element { } if namespace == namespace::Null { - self.after_set_attr(abstract_self, local_name, value, old_raw_value); + self.after_set_attr(abstract_self, local_name, value); } Ok(()) } @@ -232,8 +236,7 @@ impl Element { fn after_set_attr(&mut self, abstract_self: &JS, local_name: DOMString, - value: DOMString, - old_value: Option) { + value: DOMString) { match local_name.as_slice() { "style" => { @@ -248,7 +251,7 @@ impl Element { // "borrowed value does not live long enough" let mut doc = self.node.owner_doc(); let doc = doc.get_mut(); - doc.update_idmap(abstract_self, Some(value.clone()), old_value); + doc.register_named_element(abstract_self, value.clone()); } } _ => ()