From 57a85b101719ce224419b96ac177da6ff3e9ce18 Mon Sep 17 00:00:00 2001 From: sin-ack Date: Tue, 15 Mar 2022 01:13:05 +0000 Subject: [PATCH] LibWeb: Ensure that radio group is updated when radio is checked from JS Fixes test 56 in Acid3. Farewell, radio eyes, you will be missed. :^( --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 12 ++++++++++++ Userland/Libraries/LibWeb/HTML/HTMLInputElement.h | 3 +++ Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 834d05a8be..1269c149be 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -70,6 +70,18 @@ void HTMLInputElement::set_checked(bool checked, ChangeSource change_source) set_needs_style_update(true); } +void HTMLInputElement::set_checked_binding(bool checked) +{ + if (type() == "radio") { + if (checked) + set_checked_within_group(); + else + set_checked(false, ChangeSource::Programmatic); + } else { + set_checked(checked, ChangeSource::Programmatic); + } +} + // https://html.spec.whatwg.org/multipage/input.html#input-activation-behavior void HTMLInputElement::run_input_activation_behavior() { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index e0d22f363d..4a8794a000 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -69,6 +69,9 @@ public: }; void set_checked(bool, ChangeSource = ChangeSource::Programmatic); + bool checked_binding() const { return checked(); } + void set_checked_binding(bool); + void did_edit_text_node(Badge); virtual bool is_focusable() const override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl index e4f1b9083c..19c814c8dc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl @@ -21,7 +21,7 @@ interface HTMLInputElement : HTMLElement { [LegacyNullToEmptyString] attribute DOMString value; - attribute boolean checked; + [ImplementedAs=checked_binding] attribute boolean checked; [Reflect] attribute boolean disabled; [Reflect=checked] attribute boolean defaultChecked;