Implement SetNamedItem, SetNamedItemNS, SetAttributeNode and SetAttributeNodeNS

This commit is contained in:
Mathieu Hordesseaux 2015-12-23 17:21:45 +01:00
parent bc44ae679f
commit 322b120f8a
11 changed files with 105 additions and 67 deletions

View file

@ -193,16 +193,12 @@ impl Attr {
pub fn set_owner(&self, owner: Option<&Element>) {
let ns = &self.identifier.namespace;
match (self.owner().r(), owner) {
(None, Some(new)) => {
// Already in the list of attributes of new owner.
assert!(new.get_attribute(&ns, &self.identifier.local_name) ==
Some(Root::from_ref(self)))
}
(Some(old), None) => {
// Already gone from the list of attributes of old owner.
assert!(old.get_attribute(&ns, &self.identifier.local_name).is_none())
assert!(old.get_attribute(&ns, &self.identifier.local_name).r() != Some(self))
}
(old, new) => assert!(old == new),
(Some(old), Some(new)) => assert!(old == new),
_ => {},
}
self.owner.set(owner);
}