Move ID management on binding to and unbinding from tree into Element.

This commit is contained in:
Ms2ger 2014-02-25 16:04:25 +01:00
parent 7ff35c0abe
commit 33792db657
3 changed files with 62 additions and 38 deletions

View file

@ -646,6 +646,33 @@ impl Element {
}
}
pub trait IElement {
fn bind_to_tree_impl(&self);
fn unbind_from_tree_impl(&self);
}
impl IElement for JS<Element> {
fn bind_to_tree_impl(&self) {
match self.get().get_attribute(Null, "id") {
Some(attr) => {
let mut doc = self.get().node.owner_doc();
doc.get_mut().register_named_element(self, attr.get().Value());
}
_ => ()
}
}
fn unbind_from_tree_impl(&self) {
match self.get().get_attribute(Null, "id") {
Some(attr) => {
let mut doc = self.get().node.owner_doc();
doc.get_mut().unregister_named_element(attr.get().Value());
}
_ => ()
}
}
}
fn get_attribute_parts(name: DOMString) -> (Option<~str>, ~str) {
//FIXME: Throw for XML-invalid names
//FIXME: Throw for XMLNS-invalid names