LibWeb/CSS: Only try to fetch @imports with a parent style sheet

When `CSSRuleList::remove_a_css_rule()` is called, the removed rule has
its parent style sheet set to null. We shouldn't try to fetch an import
in this case.
This commit is contained in:
Sam Atkins 2025-04-09 11:33:18 +01:00 committed by Tim Ledbetter
parent 1d9902e22c
commit ca0890ce16
Notes: github-actions[bot] 2025-04-09 17:47:18 +00:00

View file

@ -56,7 +56,10 @@ void CSSImportRule::set_parent_style_sheet(CSSStyleSheet* parent_style_sheet)
// Crude detection of whether we're already fetching.
if (m_style_sheet || m_document_load_event_delayer.has_value())
return;
fetch();
// Only try to fetch if we now have a parent
if (parent_style_sheet)
fetch();
}
// https://www.w3.org/TR/cssom/#serialize-a-css-rule