diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index f1ddfc9f378..c58313f6ee0 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -4603,6 +4603,15 @@ impl StyleSheetListOwner for Dom { .is_before(sheet_in_doc.owner.upcast()) }) .cloned(); + + self.window + .layout_chan() + .send(Msg::AddStylesheet( + sheet.clone(), + insertion_point.as_ref().map(|s| s.sheet.clone()), + )) + .unwrap(); + self.document_or_shadow_root.add_stylesheet( owner, stylesheets, diff --git a/components/script/dom/documentorshadowroot.rs b/components/script/dom/documentorshadowroot.rs index 80b0e0022ba..70e49ca5ad5 100644 --- a/components/script/dom/documentorshadowroot.rs +++ b/components/script/dom/documentorshadowroot.rs @@ -253,14 +253,6 @@ impl DocumentOrShadowRoot { "Wat" ); - self.window - .layout_chan() - .send(Msg::AddStylesheet( - sheet.clone(), - insertion_point.as_ref().map(|s| s.sheet.clone()), - )) - .unwrap(); - let sheet = StyleSheetInDocument { sheet, owner: Dom::from_ref(owner),