Implements Stylesheet.ownerNode

This commit is contained in:
Vincent Ricard 2020-10-08 22:30:22 +02:00
parent 406d15974f
commit e7199c029f
14 changed files with 72 additions and 39 deletions

View file

@ -116,7 +116,7 @@ impl HTMLLinkElement {
stylesheets_owner.remove_stylesheet(self.upcast(), s)
}
*self.stylesheet.borrow_mut() = Some(s.clone());
self.cssom_stylesheet.set(None);
self.clean_stylesheet_ownership();
stylesheets_owner.add_stylesheet(self.upcast(), s);
}
@ -148,6 +148,13 @@ impl HTMLLinkElement {
None => false,
}
}
fn clean_stylesheet_ownership(&self) {
if let Some(cssom_stylesheet) = self.cssom_stylesheet.get() {
cssom_stylesheet.set_owner(None);
}
self.cssom_stylesheet.set(None);
}
}
fn get_attr(element: &Element, local_name: &LocalName) -> Option<String> {
@ -255,6 +262,7 @@ impl VirtualMethods for HTMLLinkElement {
}
if let Some(s) = self.stylesheet.borrow_mut().take() {
self.clean_stylesheet_ownership();
stylesheets_owner_from_node(self).remove_stylesheet(self.upcast(), &s);
}
}