New issue
Advanced search Search tips

Issue 868967 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Jul 30
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

RadioNodeList#value doesn't return the proper value

Reported by zfri...@gmail.com, Jul 30

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

Steps to reproduce the problem:
1. HTML code includes three input radio buttons with the same name and different values wrapped inside of a fieldset element. 

<fieldset>
<legend>title</legend>
<input type="radio" name="demo" value="this">
<input type="radio" name="demo" value="or">
<input type="radio" name="demo" value="that">
</fieldset>

2. Add an event listener to each radio. When clicked we use a selector to grab the fieldset and display fieldset.elements.demo.value in the console.

document.querySelectorAll("[name='demo']").forEach(item =>
  item.addEventListener("click", function() {
 console.log(document.querySelector("fieldset").elements.demo.value);
  }));

What is the expected behavior?
The value according to all of the documentation should be the value of the first radio input that has been checked.

What went wrong?
It continuously returns the first radio value regardless of what is checked.

Did this work before? N/A 

Chrome version: 67.0.3396.99  Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version: 

http://jsfiddle.net/qorkn5wd/23/
 
Bisected to 58c06a5f1b87ec32101c95e17f52189fed28158a
"FIELDSET element: |elements| IDL attribute should return an HTMLCollection, not HTMLFormControlsCollection."
Landed in 57.0.2940.0

The new behavior matches the specification:
https://html.spec.whatwg.org/multipage/form-elements.html#the-fieldset-element

Firefox behaves the same.

Solution: put your <fieldset> inside <form> and access fieldsetElement.form.elements.demo or directly formElement.elements.demo
Components: -Blink Blink>Forms>Radio
Sounds like a plan. I assumed incorrectly that I would be able to access a field set without wrapping it in a form tag. Truthfully I hope at some point in the future that selectors will be able to determine if a collection is full of radio inputs dynamically, and therefore return a value property that indicates the checked elements value or undefined. Until then I'll just code around it.
Components: -Blink>Forms>Radio Blink>Forms>Fieldset
Status: WontFix (was: Unconfirmed)

Sign in to add a comment