mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 02:26:10 +00:00
LibWeb: Don't apply disabled adopted style sheets to the document
Previously, we would apply any adopted style sheet to the document if its alternate flag was not set. This meant that all adopted style sheets would be applied, since constructed style sheets never have this flag set.
This commit is contained in:
parent
84193f2746
commit
f4e0c5395a
Notes:
sideshowbarker
2024-07-17 17:06:59 +09:00
Author: https://github.com/tcl3
Commit: f4e0c5395a
Pull-request: https://github.com/SerenityOS/serenity/pull/24150
3 changed files with 22 additions and 1 deletions
20
Tests/LibWeb/Text/input/css/constructed-style-sheets.html
Normal file
20
Tests/LibWeb/Text/input/css/constructed-style-sheets.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
function constructedStyleSheetAppliesToDocument(options) {
|
||||
const textDiv = document.createElement("div");
|
||||
document.body.appendChild(textDiv);
|
||||
const sheet = new CSSStyleSheet(options);
|
||||
const newColor = "rgb(0, 128, 0)";
|
||||
sheet.replaceSync(`div { color: ${newColor}; }`);
|
||||
document.adoptedStyleSheets = [sheet];
|
||||
const styleSheetAppliedToDocument = getComputedStyle(textDiv).color === newColor;
|
||||
document.body.removeChild(textDiv);
|
||||
document.adoptedStyleSheets = [];
|
||||
return styleSheetAppliedToDocument;
|
||||
}
|
||||
|
||||
println(`Disabled constructed style sheet applies to document: ${constructedStyleSheetAppliesToDocument({ disabled: true })}`);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue