This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25997 - Behaviour when dynamically adding <option selected=""> is underspecified
Summary: Behaviour when dynamically adding <option selected=""> is underspecified
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-05 23:28 UTC by caitp
Modified: 2014-08-06 23:12 UTC (History)
3 users (show)

See Also:


Attachments

Description caitp 2014-06-05 23:28:42 UTC
I'm not totally sure about this due to not being deeply familiar with this area of the spec. Igor Minar had put together a minimal reproduction of an issue regarding this, which may be added to a bug on Chromium/Blink (http://jsfiddle.net/Wz59M/1/)

Before filing a bug, I wanted to figure out if there is a "specified" behaviour, and it's not clear that there really is a specific behaviour which should be followed, so I'm hoping to have that cleared up.

Our preference is that the dynamically inserted node's selected property should not be ignored.

Just for logging purposes, from #whatwg on Freenode:

> [19:02]  <caitp> can anyone explain what "should" happen in a case like this? > http://jsfiddle.net/Wz59M/1/
> [19:02]  * ap has quit (Ping timeout: 240 seconds)
> [19:02]  * ap__ is now known as ap
> [19:02]  <caitp> other than crashing FF nightly, that probably isn't supposed to happen
> [19:03]  <caitp> basically, from angular's POV, chrome is doing the "wrong thing" here, and firefox is doing the "right thing", but I just want to get a feel for "why" one or the other is the right thing
> [19:05]  <Hixie> half-way through the script, there's no options at all
> [19:05]  <Hixie> then you insert one
> [19:05]  <Hixie> so it's selected
> [19:05]  <Hixie> then you insert another
> [19:05]  <Hixie> and, well, there's already a selected one
> [19:06]  <othermaciej> I would expect “don’t show me” to show
> [19:07]  <Hixie> this is why the insertd one is selected: "If nodes are > inserted or nodes are removed causing the list of options to gain or lose one or more option elements, or if an option element in the list of options asks for a reset, then, if the select element's multiple attribute is absent, the select element's display size is 1, and no option elements in the select element's list of options have their selectedness set to true, the user agent must set the selectedness
> [19:07]  <caitp> I think the issue is that, `x` does already have a selected option
> [19:07]  <caitp> you add another option which isn't selected, but chrome decides that it is selected
> [19:08]  <caitp> oh, we are removing the selected option
> [19:08]  <othermaciej> yeah, the selected option is removed before a new one is added
> [19:08]  <Hixie> i don't see anything in the spec that says what should happen when you add a second selected one...
> [19:08]  <caitp> okay, so inserting an option into a select with no options should select that option
> [19:08]  <Hixie> that's probably a bug...
> [19:08]  <Hixie> caitp: yeah, that part is clear
> [19:08]  <Hixie> caitp: it's the next insertion that's unclear to me
Comment 1 Ian 'Hixie' Hickson 2014-08-06 23:11:53 UTC
I fixed the thing that that IRC log says is undefined. Let me know if something else is still undefined.
Comment 2 contributor 2014-08-06 23:12:13 UTC
Checked in as WHATWG revision r8714.
Check-in comment: Try to define what happens when you insert multiple <option selected> elements into a <select> element.
http://html5.org/tools/web-apps-tracker?from=8713&to=8714