LibWeb/DOM: Use document's URL as location for inline stylesheets

This is ad-hoc, and the spec doesn't seem to tell us what to actually do
here. Without this, following the spec steps for loading relative
`@import` URLs from a `<style>` tag always fails, because that uses the
parent style sheet's location as the base URL.
This commit is contained in:
Sam Atkins 2025-04-08 15:37:20 +01:00 committed by Tim Ledbetter
parent bc02e3e9a9
commit a8ab4d64c4
Notes: github-actions[bot] 2025-04-09 17:47:44 +00:00

View file

@ -54,7 +54,8 @@ void StyleElementUtils::update_a_style_block(DOM::Element& style_element)
// FIXME: This is a bit awkward, as the spec doesn't actually tell us when to parse the CSS text,
// so we just do it here and pass the parsed sheet to create_a_css_style_sheet().
auto* sheet = parse_css_stylesheet(CSS::Parser::ParsingParams(style_element.document()), style_element.text_content().value_or(String {}));
// AD-HOC: Are we supposed to use the document's URL for the stylesheet's location? Not doing it breaks things.
auto* sheet = parse_css_stylesheet(CSS::Parser::ParsingParams(style_element.document()), style_element.text_content().value_or(String {}), style_element.document().url());
if (!sheet)
return;