Force HTMLStyleElement to create a new CSSStyleSheet when re-parsing.

We already call Document::invalidate_style_sheets and set
the stylesheet member to a new Stylesheet. This matches the behavior of
Firefox, and means the new CSSStyleSheet you get from accessing .sheet
from JS will be correct instead of stale.

(::get_cssom_stylesheet already tries to use the new Stylesheet, but
MutNullableJS::or_init is called, so if we already created a
CSSStyleSheet we will continue to return that one).
This commit is contained in:
Jonathan Chan 2017-06-07 10:22:49 -07:00
parent b9d66df2f5
commit 80dee7a65f
5 changed files with 13 additions and 248 deletions

View file

@ -111,6 +111,7 @@ impl HTMLStyleElement {
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();
*self.stylesheet.borrow_mut() = Some(sheet);
self.cssom_stylesheet.set(None);
doc.invalidate_stylesheets();
}