Open Bug 1421260 Opened 7 years ago Updated 2 years ago

option.selected suddenly changes to true for no reason

Categories

(Core :: DOM: Core & HTML, defect, P3)

57 Branch
defect

Tracking

()

People

(Reporter: andrea.giammarchi, Unassigned)

Details

Attachments

(1 file)

Attached file firefox-bug.html
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36

Steps to reproduce:

I have used a diffing algorithm to update a <SELECT> element with fresh new options.

You can test the break down of the issue in this CodePen:
https://codepen.io/WebReflection/pen/WXaeWj?editors=0010


Actual results:

The <SELECT> shows a different selected options compared to any other browser. Nobody set the option.selected = true to the first item of the select.


Expected results:

The select should accept new option nodes, eventually flag as non selected the previously live selected one and **never** set selected = true to random nodes.
Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Jessica knows more about <select> than I do so I'll needinfo her.

Anne, is it spec-compliant to set option.selected = true for the first item of the <select> element?
Flags: needinfo?(jjong)
Flags: needinfo?(annevk)
It seems Firefox does not implement this bit from the HTML Standard:

> If the multiple attribute is absent, whenever an option element in the select element's list of options has its selectedness set to true, and whenever an option element with its selectedness set to true is added to the select element's list of options, the user agent must set the selectedness of all the other option elements in its list of options to false.

Possibly there's some confusion with later requirements around manipulating the contents of select elements, but nothing supports Firefox's behavior.
Flags: needinfo?(annevk)
Also, this:

> If two or more option elements in the select element's list of options have their selectedness set to true
>  Set the selectedness of all but the last option element with its selectedness set to true in the list of options in tree order to false.

So, yes, it's a bug in Firefox. Let me get back to this later.
Assignee: nobody → jjong
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(jjong)
Priority: -- → P2
I remembered when I was debugging, it was because we call CheckSelecSomething [1] in HTMLSelectElement::SetOptionsSelectedByIndex, so maybe we should call the function with mask NO_RESELECT somewhere.
A little hint for anyone who is taking this bug in the future. :)


[1] https://searchfox.org/mozilla-central/rev/2031c0f517185b2bd0e8f6f92f9491b3410c1f7f/dom/html/HTMLSelectElement.cpp#961
Assignee: jessi3py → nobody
Status: ASSIGNED → NEW
I’ll take this one, but will do it in my spare time. Setting to P3 until I actually start working on it.
Assignee: nobody → mcaceres
Priority: P2 → P3

No longer working on DOM Team, so removing myself.

Assignee: mcaceres → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: