Truly independent web browser
LibWeb: Restyle element-backed pseudo-elements on custom property change
Tim Ledbetter1f45f52da0f4
diff --git a/Libraries/LibWeb/Rust/src/css/style/custom_property_cascade.rs b/Libraries/LibWeb/Rust/src/css/style/custom_property_cascade.rsindex c6d50408352..7cb8ce856c0 100644--- a/Libraries/LibWeb/Rust/src/css/style/custom_property_cascade.rs+++ b/Libraries/LibWeb/Rust/src/css/style/custom_property_cascade.rs@@ -897,7 +897,7 @@ impl RetainedState {}let reads_any = |reads: &[Arc<[u16]>]| reads.iter().any(|read| names.binary_search(read).is_ok());let groups = self.current_winner_groups();- let Lookup::Known((_, state)) = groups.token_for(WinnerGroupKey::current(node, self.program.version())) else {+ let Some(state) = self.element_record_winner_state(node) else {return true;};let states_read_any = std::iter::once(state)diff --git a/Tests/LibWeb/Text/expected/css/element-backed-pseudo-element-custom-properties.txt b/Tests/LibWeb/Text/expected/css/element-backed-pseudo-element-custom-properties.txtnew file mode 100644index 00000000000..5a65e0bce7d--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/element-backed-pseudo-element-custom-properties.txt@@ -0,0 +1,2 @@+before: rgb(255, 0, 0), rgb(255, 0, 0)+after a root class change: rgb(0, 128, 0), rgb(0, 128, 0), child rgb(0, 128, 0)diff --git a/Tests/LibWeb/Text/input/css/element-backed-pseudo-element-custom-properties.html b/Tests/LibWeb/Text/input/css/element-backed-pseudo-element-custom-properties.htmlnew file mode 100644index 00000000000..dc6274fab57--- /dev/null+++ b/Tests/LibWeb/Text/input/css/element-backed-pseudo-element-custom-properties.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ :root {+ --shade: rgb(255, 0, 0);+ }+ :root.dark {+ --shade: rgb(0, 128, 0);+ }+ input::placeholder, details::details-content {+ color: var(--shade);+ }+</style>+<input id="input" placeholder="Placeholder">+<details id="details" open><summary>Summary</summary><p>Content</p></details>+<script>+ test(() => {+ const placeholderStyle = getComputedStyle(input, "::placeholder");+ const detailsContentStyle = getComputedStyle(details, "::details-content");+ println(`before: ${placeholderStyle.color}, ${detailsContentStyle.color}`);++ document.documentElement.classList.add("dark");+ println(`after a root class change: ${placeholderStyle.color}, ${detailsContentStyle.color}, child ${getComputedStyle(details.querySelector("p")).color}`);+ });+</script>