Removing style element's styles when elements is removed from dom

This commit is contained in:
Roman Zaynetdinov 2017-01-09 19:39:13 +02:00
parent b3ce08f1b5
commit f0c72cb7fd
4 changed files with 59 additions and 1 deletions

View file

@ -15,7 +15,7 @@ use dom::document::Document;
use dom::element::{Element, ElementCreator};
use dom::eventtarget::EventTarget;
use dom::htmlelement::HTMLElement;
use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node};
use dom::node::{ChildrenMutation, Node, UnbindContext, document_from_node, window_from_node};
use dom::stylesheet::StyleSheet as DOMStyleSheet;
use dom::virtualmethods::VirtualMethods;
use html5ever_atoms::LocalName;
@ -161,6 +161,15 @@ impl VirtualMethods for HTMLStyleElement {
self.parse_own_css();
}
}
fn unbind_from_tree(&self, context: &UnbindContext) {
if let Some(ref s) = self.super_type() {
s.unbind_from_tree(context);
}
let doc = document_from_node(self);
doc.invalidate_stylesheets();
}
}
impl StylesheetOwner for HTMLStyleElement {