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

@ -144,7 +144,7 @@ impl HTMLStyleElement {
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);
}
@ -166,6 +166,13 @@ impl HTMLStyleElement {
})
})
}
fn clean_stylesheet_ownership(&self) {
if let Some(cssom_stylesheet) = self.cssom_stylesheet.get() {
cssom_stylesheet.set_owner(None);
}
self.cssom_stylesheet.set(None);
}
}
impl VirtualMethods for HTMLStyleElement {
@ -217,6 +224,7 @@ impl VirtualMethods for HTMLStyleElement {
if context.tree_connected {
if let Some(s) = self.stylesheet.borrow_mut().take() {
self.clean_stylesheet_ownership();
stylesheets_owner_from_node(self).remove_stylesheet(self.upcast(), &s)
}
}