summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathis Wiehl <mail@mathiswiehl.de>2023-03-18 15:45:54 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-18 16:01:12 +0100
commit8169b878f839a2745ffd938945065ef7f30b1291 (patch)
treee6cc65eb596dac9d91103d7620ecd84dbc3f55e9
parentcabc99e953ffdab1496e92b041da86c947f88c9d (diff)
downloadserenity-8169b878f839a2745ffd938945065ef7f30b1291.zip
LibWeb: Invalidate sibling styles on input element checked state change
Checkedness of an input element can influence sibling style, as well as style of their children, when they use the `:checked` pseudo-class in combination with a kind of sibling selector. That means its not sufficient to just invalidate the input elements on style. This is actually more commonly observable than one might expect, because this pattern is often used as a JS-free toggle solution for things like menus.
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index 3b49810840..3b2ba90978 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -85,7 +85,12 @@ void HTMLInputElement::set_checked(bool checked, ChangeSource change_source)
m_dirty_checkedness = true;
m_checked = checked;
- set_needs_style_update(true);
+
+ // This element's :checked pseudo-class could be used in a sibling's sibling-selector,
+ // so we need to invalidate the style of all siblings.
+ parent()->for_each_child([&](auto& child) {
+ child.invalidate_style();
+ });
}
void HTMLInputElement::set_checked_binding(bool checked)