Skip to content
Permalink
Browse files

[giow] (3) Move more towards the browsers for <option> selectedness v…

…s dirtiness. This doesn't quite match any browser exactly, so all browsers would have to change to match it. If there's a reason (e.g. backcompat) to prefer a different model, please reopen the bug and let me know.

Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=23574
Affected topics: DOM APIs, HTML

git-svn-id: http://svn.whatwg.org/webapps@8297 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
Hixie committed Nov 19, 2013
1 parent c4838ee commit 919de244e690d6d4d91519ba7ba0e56f9bc37985
Showing with 75 additions and 32 deletions.
  1. +24 −10 complete.html
  2. +24 −10 index
  3. +27 −12 source


<div class=impl> <div class=impl>


<!--CLEANUP-->
<p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent, and the element <p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent, and the element
is not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, then the user agent should allow the is not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, then the user agent should allow the
user to pick an <code><a href=#the-option-element>option</a></code> element in its <a href=#concept-select-option-list title=concept-select-option-list>list user to pick an <code><a href=#the-option-element>option</a></code> element in its <a href=#concept-select-option-list title=concept-select-option-list>list
through a click, or through unfocusing the element after changing its value, or through a <a href=#using-the-option-element-to-define-a-command title=option-command>menu command</a>, or through any other mechanism), and before the through a click, or through unfocusing the element after changing its value, or through a <a href=#using-the-option-element-to-define-a-command title=option-command>menu command</a>, or through any other mechanism), and before the
relevant user interaction event <!-- interaction event spec point --> is queued (e.g. before the relevant user interaction event <!-- interaction event spec point --> is queued (e.g. before the
<code title=event-click><a href=#event-click>click</a></code> event), the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of the picked <code><a href=#the-option-element>option</a></code> element <code title=event-click><a href=#event-click>click</a></code> event), the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of the picked <code><a href=#the-option-element>option</a></code> element
to true and then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named to true, set its <a href=#concept-option-dirtiness title=concept-option-dirtiness>dirtiness</a> to true, and then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named
<code title=event-change>change</code> at the <code><a href=#the-select-element>select</a></code> element, using the <a href=#user-interaction-task-source>user <code title=event-change>change</code> at the <code><a href=#the-select-element>select</a></code> element, using the <a href=#user-interaction-task-source>user
interaction task source</a> as the task source.</p> interaction task source</a> as the task source.</p>


set to true is added to the <code><a href=#the-select-element>select</a></code> element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>, the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of all the other <code><a href=#the-option-element>option</a></code> set to true is added to the <code><a href=#the-select-element>select</a></code> element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>, the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of all the other <code><a href=#the-option-element>option</a></code>
elements in its <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> to false.</p> elements in its <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> to false.</p>


<!--CLEANUP-->
<p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent and the element's <p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is absent and the element's
<a href=#concept-select-size title=concept-select-size>display size</a> is greater than 1, then the user agent <a href=#concept-select-size title=concept-select-size>display size</a> is greater than 1, then the user agent
should also allow the user to request that the <code><a href=#the-option-element>option</a></code> whose <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is true, if any, be unselected. Upon this should also allow the user to request that the <code><a href=#the-option-element>option</a></code> whose <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is true, if any, be unselected. Upon this
request being conveyed to the user agent, and before the relevant user interaction event <!-- request being conveyed to the user agent, and before the relevant user interaction event <!--
interaction event spec point --> is queued (e.g. before the <code title=event-click><a href=#event-click>click</a></code> interaction event spec point --> is queued (e.g. before the <code title=event-click><a href=#event-click>click</a></code>
event), the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> event), the user agent must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a>
of that <code><a href=#the-option-element>option</a></code> element to false and then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a of that <code><a href=#the-option-element>option</a></code> element to false, set its <a href=#concept-option-dirtiness title=concept-option-dirtiness>dirtiness</a> to true, and then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a
simple event</a> that bubbles named <code title=event-change>change</code> at the simple event</a> that bubbles named <code title=event-change>change</code> at the
<code><a href=#the-select-element>select</a></code> element, using the <a href=#user-interaction-task-source>user interaction task source</a> as the task <code><a href=#the-select-element>select</a></code> element, using the <a href=#user-interaction-task-source>user interaction task source</a> as the task
source.</p> source.</p>
the first <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of the first <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of
options</a> in <a href=#tree-order>tree order</a> that is not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a>, if any, to true.</p> options</a> in <a href=#tree-order>tree order</a> that is not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a>, if any, to true.</p>


<!--CLEANUP-->
<p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is present, and the element <p>If the <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute is present, and the element
is not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, then the user agent should allow the is not <a href=#concept-fe-disabled title=concept-fe-disabled>disabled</a>, then the user agent should allow the
user to <dfn id=concept-select-toggle title=concept-select-toggle>toggle</dfn> the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of the <code><a href=#the-option-element>option</a></code> elements in its user to <dfn id=concept-select-toggle title=concept-select-toggle>toggle</dfn> the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of the <code><a href=#the-option-element>option</a></code> elements in its
<a href=#concept-select-option-list title=concept-select-option-list>list of options</a> that are themselves not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a> (either through a click, or through a <a href=#using-the-option-element-to-define-a-command title=option-command>menu command</a>, or any other mechanism). Upon the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of one or more <code><a href=#the-option-element>option</a></code> <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> that are themselves not <a href=#concept-option-disabled title=concept-option-disabled>disabled</a>. Upon such an element being <a href=#concept-select-toggle title=concept-select-toggle>toggled</a> (either through a click, or through a <a href=#using-the-option-element-to-define-a-command title=option-command>menu command</a>, or any other mechanism), and before the relevant user interaction event <!--
elements being changed by the user, and before the relevant user interaction event <!-- interaction event spec point --> is queued (e.g. before a related <code title=event-click><a href=#event-click>click</a></code> event), the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of the <code><a href=#the-option-element>option</a></code>
interaction event spec point --> is queued (e.g. before a related <code title=event-click><a href=#event-click>click</a></code> event), the user agent must <a href=#queue-a-task>queue a task</a> to element must be changed (from true to false or false to true), the <a href=#concept-option-dirtiness title=concept-option-dirtiness>dirtiness</a> of the element must be set to true, and the user agent must <a href=#queue-a-task>queue a task</a> to
<a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at <a href=#fire-a-simple-event>fire a simple event</a> that bubbles named <code title=event-change>change</code> at
the <code><a href=#the-select-element>select</a></code> element, using the <a href=#user-interaction-task-source>user interaction task source</a> as the task the <code><a href=#the-select-element>select</a></code> element, using the <a href=#user-interaction-task-source>user interaction task source</a> as the task
source.</p> source.</p>


<!--CLEANUP-->
<p>The <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> for <code><a href=#the-select-element>select</a></code> <p>The <a href=#concept-form-reset-control title=concept-form-reset-control>reset algorithm</a> for <code><a href=#the-select-element>select</a></code>
elements is to go through all the <code><a href=#the-option-element>option</a></code> elements in the element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>, set their <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> to true if the <code><a href=#the-option-element>option</a></code> element elements is to go through all the <code><a href=#the-option-element>option</a></code> elements in the element's <a href=#concept-select-option-list title=concept-select-option-list>list of options</a>, set their <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> to true if the <code><a href=#the-option-element>option</a></code> element
has a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute, and false otherwise, and then has a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute, and false otherwise, set their <a href=#concept-option-dirtiness title=concept-option-dirtiness>dirtiness</a> to false, and then
have the <code><a href=#the-option-element>option</a></code> elements <a href=#ask-for-a-reset>ask for a reset</a>.</p> have the <code><a href=#the-option-element>option</a></code> elements <a href=#ask-for-a-reset>ask for a reset</a>.</p>


</div> </div>
in <a href=#tree-order>tree order</a> that has its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true, if any. If there isn't one, in <a href=#tree-order>tree order</a> that has its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true, if any. If there isn't one,
then it must return &minus;1.</p> then it must return &minus;1.</p>


<!--CLEANUP-->
<p>On setting, the <code title=dom-select-selectedIndex><a href=#dom-select-selectedindex>selectedIndex</a></code> attribute must set <p>On setting, the <code title=dom-select-selectedIndex><a href=#dom-select-selectedindex>selectedIndex</a></code> attribute must set
the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of all the <code><a href=#the-option-element>option</a></code> the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of all the <code><a href=#the-option-element>option</a></code>
elements in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> to false, and then elements in the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> to false, and then
the <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of the <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of
options</a> whose <a href=#concept-option-index title=concept-option-index>index</a> is the given new value, if options</a> whose <a href=#concept-option-index title=concept-option-index>index</a> is the given new value, if
any, must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true.</p> any, must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true and its <a href=#concept-option-dirtiness title=concept-option-dirtiness>dirtiness</a> set to true.</p>


<p class=note>This can result in no element having a <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true even in the case of the <p class=note>This can result in no element having a <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true even in the case of the
<code><a href=#the-select-element>select</a></code> element having no <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute <code><a href=#the-select-element>select</a></code> element having no <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute
order</a> that has its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to order</a> that has its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to
true, if any. If there isn't one, then it must return the empty string.</p> true, if any. If there isn't one, then it must return the empty string.</p>


<!--CLEANUP-->
<p>On setting, the <code title=dom-select-value><a href=#dom-select-value>value</a></code> attribute must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of all the <code><a href=#the-option-element>option</a></code> elements in <p>On setting, the <code title=dom-select-value><a href=#dom-select-value>value</a></code> attribute must set the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> of all the <code><a href=#the-option-element>option</a></code> elements in
the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> to false, and then the first the <a href=#concept-select-option-list title=concept-select-option-list>list of options</a> to false, and then the first
<code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of <code><a href=#the-option-element>option</a></code> element in the <a href=#concept-select-option-list title=concept-select-option-list>list of
options</a>, in <a href=#tree-order>tree order</a>, whose <a href=#concept-option-value title=concept-option-value>value</a> options</a>, in <a href=#tree-order>tree order</a>, whose <a href=#concept-option-value title=concept-option-value>value</a>
is equal to the given new value, if any, must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true.</p> is equal to the given new value, if any, must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true and its <a href=#concept-option-dirtiness title=concept-option-dirtiness>dirtiness</a> set to true.</p>


<p class=note>This can result in no element having a <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true even in the case of the <p class=note>This can result in no element having a <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true even in the case of the
<code><a href=#the-select-element>select</a></code> element having no <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute <code><a href=#the-select-element>select</a></code> element having no <code title=attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> attribute


<div class=impl> <div class=impl>


<p>The <dfn id=concept-option-dirtiness title=concept-option-dirtiness>dirtiness</dfn> of an <code><a href=#the-option-element>option</a></code> element is
a boolean state, initially false. It controls whether adding or removing the <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> content attribute has any effect.</p>

<!--CLEANUP-->
<p>The <dfn id=concept-option-selectedness title=concept-option-selectedness>selectedness</dfn> of an <code><a href=#the-option-element>option</a></code> <p>The <dfn id=concept-option-selectedness title=concept-option-selectedness>selectedness</dfn> of an <code><a href=#the-option-element>option</a></code>
element is a boolean state, initially false. Except where otherwise specified, when the element is element is a boolean state, initially false. Except where otherwise specified, when the element is
created, its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be set to true if created, its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be set to true if
the element has a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute. Whenever an the element has a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute. Whenever an
<code><a href=#the-option-element>option</a></code> element's <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute is <code><a href=#the-option-element>option</a></code> element's <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute is
added, its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be set to true.</p> added, if its <a href=#concept-option-dirtiness title=concept-option-dirtiness>dirtiness</a> is true, its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be set to true.
Whenever an
<code><a href=#the-option-element>option</a></code> element's <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute is
<em>removed</em>, if its <a href=#concept-option-dirtiness title=concept-option-dirtiness>dirtiness</a> is true, its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be set to false.</p>


<p class=note>The <code title=dom-option><a href=#dom-option>Option()</a></code> constructor, when called with three <p class=note>The <code title=dom-option><a href=#dom-option>Option()</a></code> constructor, when called with three
or fewer arguments, overrides the initial state of the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> state to always be false even if the third or fewer arguments, overrides the initial state of the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> state to always be false even if the third
return the element's <a href=#concept-option-value title=concept-option-value>value</a>. On setting, the element's return the element's <a href=#concept-option-value title=concept-option-value>value</a>. On setting, the element's
<code title=attr-option-value><a href=#attr-option-value>value</a></code> content attribute must be set to the new value.</p> <code title=attr-option-value><a href=#attr-option-value>value</a></code> content attribute must be set to the new value.</p>


<!--CLEANUP-->
<p>The <dfn id=dom-option-selected title=dom-option-selected><code>selected</code></dfn> IDL attribute, on getting, <p>The <dfn id=dom-option-selected title=dom-option-selected><code>selected</code></dfn> IDL attribute, on getting,
must return true if the element's <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is must return true if the element's <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> is
true, and false otherwise. On setting, it must set the element's <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> to the new value, and then cause the true, and false otherwise. On setting, it must set the element's <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> to the new value, set its <a href=#concept-option-dirtiness title=concept-option-dirtiness>dirtiness</a> to true, and then cause the
element to <a href=#ask-for-a-reset>ask for a reset</a>.</p> element to <a href=#ask-for-a-reset>ask for a reset</a>.</p>


<p>The <dfn id=dom-option-index title=dom-option-index><code>index</code></dfn> IDL attribute must return the <p>The <dfn id=dom-option-index title=dom-option-index><code>index</code></dfn> IDL attribute must return the

0 comments on commit 919de24

Please sign in to comment.
You can’t perform that action at this time.