mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
LibWeb: Forward media attribute from link element to loaded style sheet
Otherwise, we will treat the loaded style sheet as if it had media="all" which is not always appropriate.
This commit is contained in:
parent
a6c6c24428
commit
8a43f5a64a
Notes:
sideshowbarker
2024-07-17 06:51:40 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8a43f5a64a Pull-request: https://github.com/SerenityOS/serenity/pull/19345
4 changed files with 22 additions and 0 deletions
|
@ -0,0 +1 @@
|
|||
document background: rgb(0, 128, 0)
|
3
Tests/LibWeb/Text/input/body-background-color-red.css
Normal file
3
Tests/LibWeb/Text/input/body-background-color-red.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
body {
|
||||
background-color: red;
|
||||
}
|
17
Tests/LibWeb/Text/input/link-element-media-attribute.html
Normal file
17
Tests/LibWeb/Text/input/link-element-media-attribute.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<style>
|
||||
body {
|
||||
background: green;
|
||||
}
|
||||
</style>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
let link = document.createElement("link");
|
||||
link.setAttribute("rel", "stylesheet");
|
||||
link.setAttribute("href", "body-background-color-red.css");
|
||||
link.setAttribute("media", "print")
|
||||
document.head.appendChild(link)
|
||||
|
||||
window.onload = function() {
|
||||
println("document background: " + getComputedStyle(document.body).backgroundColor)
|
||||
}
|
||||
</script>
|
|
@ -364,6 +364,7 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru
|
|||
|
||||
if (m_loaded_style_sheet) {
|
||||
m_loaded_style_sheet->set_owner_node(this);
|
||||
m_loaded_style_sheet->set_media(attribute(HTML::AttributeNames::media));
|
||||
document().style_sheets().add_sheet(*m_loaded_style_sheet);
|
||||
} else {
|
||||
dbgln_if(CSS_LOADER_DEBUG, "HTMLLinkElement: Failed to parse stylesheet: {}", resource()->url());
|
||||
|
|
Loading…
Reference in a new issue