LibWeb: Update stylesheet media value when changing link media attribute
This commit is contained in:
parent
b92abe5c26
commit
00f75648e5
Notes:
github-actions[bot]
2024-08-13 12:13:49 +00:00
Author: https://github.com/vpzomtrrfrt Commit: https://github.com/LadybirdBrowser/ladybird/commit/00f75648e56 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1034
5 changed files with 38 additions and 0 deletions
Tests/LibWeb/Text
expected
input
Userland/Libraries/LibWeb/HTML
|
@ -0,0 +1 @@
|
|||
document background: rgba(0, 0, 0, 0)
|
1
Tests/LibWeb/Text/expected/link-element-media-change.txt
Normal file
1
Tests/LibWeb/Text/expected/link-element-media-change.txt
Normal file
|
@ -0,0 +1 @@
|
|||
document background: rgb(255, 0, 0)
|
16
Tests/LibWeb/Text/input/link-element-media-change-off.html
Normal file
16
Tests/LibWeb/Text/input/link-element-media-change-off.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="body-background-color-red.css" media="all" onload="this.media='none'">
|
||||
</head>
|
||||
<body>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
window.onload = function () {
|
||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
16
Tests/LibWeb/Text/input/link-element-media-change.html
Normal file
16
Tests/LibWeb/Text/input/link-element-media-change.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="body-background-color-red.css" media="print" onload="this.media='all'">
|
||||
</head>
|
||||
<body>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
window.onload = function () {
|
||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -187,6 +187,10 @@ void HTMLLinkElement::attribute_changed(FlyString const& name, Optional<String>
|
|||
)) {
|
||||
fetch_and_process_linked_resource();
|
||||
}
|
||||
|
||||
if (name == HTML::AttributeNames::media && m_loaded_style_sheet) {
|
||||
m_loaded_style_sheet->set_media(value.value_or(String {}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue