htmlinputelement: Update radio group validity logic for disconnected trees (#36431)

This PR updates the validity state revalidation behavior for radio input
elements, ensuring consistent logic regardless of tree connectivity.

---

**What’s changed:**  
- we now always update the validity state.
- Handled more edge cases for disconnected trees, shadow roots, and
cross-tree movement.
- Ensured that radio group updates still trigger when a parent is moved
into a different root.
- Updated test expectations in
`radio-disconnected-group-owner.html.ini`.

---

**Why this matters:**  
The updated logic aligns better with the [HTML
specification](https://html.spec.whatwg.org/multipage/input.html#radio-button-group),
especially regarding radio group behavior in disconnected trees or
shadow DOM.

These changes improve validity propagation in scenarios like:
- Appending inputs into a disconnected form
- Shadow roots acting as radio group containers
- Cross-tree movement of radio buttons

---

**Tests:**  
- Modified `radio-disconnected-group-owner.html.ini`
  - Removed a test that now passes
- Added a failing test expectation caused by a spec bug: the fragment
parsing algorithm uses the connected tree for HTML set via `innerHTML`,
affecting radio group computation

---

**Spec reference:**  
https://html.spec.whatwg.org/multipage/input.html#radio-button-group

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report an errors
- [ ] These changes fix #

<!-- Either: -->
- [X] There are tests for these changes

Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
This commit is contained in:
elomscansio 2025-04-28 02:24:43 +01:00 committed by GitHub
parent 2892e7924d
commit b1d0b6a37b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 8 deletions

View file

@ -1,6 +1,3 @@
[radio-disconnected-group-owner.html]
[Removed elements are moved into separate radio groups.]
expected: FAIL
[Appending input radio input into a disconnect form should update the other radio inputs in the same radio group.]
[Appending input radio input into a disconnect tree don't update the other radio inputs in the same radio group.]
expected: FAIL

View file

@ -1,3 +0,0 @@
[radio.html]
[Radio buttons in an orphan tree should make a group]
expected: FAIL