Skip to content
Permalink
Browse files

[e] (0) Option constructor: clean up to use more WebIDL features, beh…

…ave more like IE for the first argument. Add some rationale for Web Storage disk quota suggestions.

Affected topics: DOM APIs, HTML

git-svn-id: http://svn.whatwg.org/webapps@7785 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
Hixie committed Apr 1, 2013
1 parent 2aa864e commit 9e0c93730d1e9dbfc3eb76bdd5a8ad082e938376
Showing with 51 additions and 56 deletions.
  1. +16 −16 complete.html
  2. +16 −16 index
  3. +19 −24 source
<dd><code title=attr-option-value><a href=#attr-option-value>value</a></code> &mdash; Value to be used for <a href=#form-submission>form submission</a></dd>
<dt><a href=#element-dfn-dom title=element-dfn-dom>DOM interface</a>:</dt><!--TOPIC:DOM APIs-->
<dd>
<pre class=idl>[NamedConstructor=<a href=#dom-option title=dom-option>Option</a>(),
NamedConstructor=<a href=#dom-option-t title=dom-option-t>Option</a>(DOMString text),
NamedConstructor=<a href=#dom-option-tv title=dom-option-tv>Option</a>(DOMString text, DOMString value),
NamedConstructor=<a href=#dom-option-tvd title=dom-option-tvd>Option</a>(DOMString text, DOMString value, boolean defaultSelected),
NamedConstructor=<a href=#dom-option-tvds title=dom-option-tvds>Option</a>(DOMString text, DOMString value, boolean defaultSelected, boolean selected)]
<pre class=idl>[NamedConstructor=<a href=#dom-option title=dom-option>Option</a>(optional DOMString text, optional DOMString value, optional boolean defaultSelected, optional boolean selected)]
interface <dfn id=htmloptionelement>HTMLOptionElement</dfn> : <a href=#htmlelement>HTMLElement</a> {
attribute boolean <a href=#dom-option-disabled title=dom-option-disabled>disabled</a>;
readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-option-form title=dom-option-form>form</a>;
readonly attribute long <a href=#dom-option-index title=dom-option-index>index</a>;
};</pre>
</dd>
</dl><!--TOPIC:HTML--><p>The <code><a href=#the-option-element>option</a></code> element <a href=#represents>represents</a> an option
</dl><!--TOPIC:HTML--><!--CLEANUP--><p>The <code><a href=#the-option-element>option</a></code> element <a href=#represents>represents</a> an option
in a <code><a href=#the-select-element>select</a></code> element or as part of a list of suggestions
in a <code><a href=#the-datalist-element>datalist</a></code> element.</p>

<a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must
be set to true.</p>

<p class=note>The <code title=dom-option-tvd><a href=#dom-option-tvd>Option()</a></code>
constructor with three or fewer arguments overrides the initial
<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 argument is true (implying that a
<code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute is to
attribute must return the same value as the <code title=dom-fae-form><a href=#dom-fae-form>form</a></code> IDL attribute
on that <code><a href=#the-select-element>select</a></code> element. Otherwise, it must return null.</p>

<p>Several constructors are provided for creating <code><a href=#htmloptionelement>HTMLOptionElement</a></code> objects (in
addition to the factory methods from DOM such as <code title="">createElement()</code>): <dfn id=dom-option title=dom-option><code>Option()</code></dfn>, <dfn id=dom-option-t title=dom-option-t><code>Option(<var title="">text</var>)</code></dfn>, <dfn id=dom-option-tv title=dom-option-tv><code>Option(<var title="">text</var>, <var title="">value</var>)</code></dfn>, <dfn id=dom-option-tvd title=dom-option-tvd><code>Option(<var title="">text</var>, <var title="">value</var>, <var title="">defaultSelected</var>)</code></dfn>, and <dfn id=dom-option-tvds title=dom-option-tvds><code>Option(<var title="">text</var>, <var title="">value</var>, <var title="">defaultSelected</var>, <var title="">selected</var>)</code></dfn>. When invoked as constructors, these must return a new
<code><a href=#htmloptionelement>HTMLOptionElement</a></code> object (a new <code><a href=#the-option-element>option</a></code> element). If the <var title="">text</var> argument is present, the new object must have as its only child a
<code><a href=#text>Text</a></code> node whose data is the value of that argument. If the <var title="">value</var>
<!--CLEANUP-->
<p>A constructor is provided for creating <code><a href=#htmloptionelement>HTMLOptionElement</a></code> objects (in
addition to the factory methods from DOM such as <code title="">createElement()</code>):
<dfn id=dom-option title=dom-option><code>Option(<var title="">text</var>, <var title="">value</var>, <var title="">defaultSelected</var>, <var title="">selected</var>)</code></dfn>. When invoked as a constructor, it must return a new
<code><a href=#htmloptionelement>HTMLOptionElement</a></code> object (a new <code><a href=#the-option-element>option</a></code> element).
If the first argument is not the empty string, the new object must have as its only child a
<code><a href=#text>Text</a></code> node whose data is the value of that argument. Otherwise, it must have no children. If the <var title="">value</var>
argument is present, the new object must have a <code title=attr-option-value><a href=#attr-option-value>value</a></code>
attribute set with the value of the argument as its value. If the <var title="">defaultSelected</var> argument is present and true, the new object must have a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute set with no value. If the <var title="">selected</var> argument is present and true, the new object must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true; otherwise the fourth argument
is absent or false, and the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be
set to false, even if the <var title="">defaultSelected</var> argument is present and true. The
attribute set with the value of the argument as its value. If the <var title="">defaultSelected</var> argument is true, the new object must have a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute set with no value. If the <var title="">selected</var> argument is true, the new object must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true; otherwise
the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be
set to false, even if the <var title="">defaultSelected</var> argument is true. The
element's document must be the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>
of the <code><a href=#window>Window</a></code> object on which the interface object of the invoked constructor is
found.</p>


<h3 id=disk-space-0><span class=secno>11.3 </span>Disk space</h3>
<!--CLEANUP-->

<p>User agents should limit the total amount of space allowed for
storage areas.</p>
storage areas, because hostile authors could otherwise use this feature to exhaust the user's available disk space.</p>

<p>User agents should guard against sites storing data under their
origin's other affiliated sites, e.g. storing up to the limit in
32 index
<dd><code title=attr-option-value><a href=#attr-option-value>value</a></code> &mdash; Value to be used for <a href=#form-submission>form submission</a></dd>
<dt><a href=#element-dfn-dom title=element-dfn-dom>DOM interface</a>:</dt><!--TOPIC:DOM APIs-->
<dd>
<pre class=idl>[NamedConstructor=<a href=#dom-option title=dom-option>Option</a>(),
NamedConstructor=<a href=#dom-option-t title=dom-option-t>Option</a>(DOMString text),
NamedConstructor=<a href=#dom-option-tv title=dom-option-tv>Option</a>(DOMString text, DOMString value),
NamedConstructor=<a href=#dom-option-tvd title=dom-option-tvd>Option</a>(DOMString text, DOMString value, boolean defaultSelected),
NamedConstructor=<a href=#dom-option-tvds title=dom-option-tvds>Option</a>(DOMString text, DOMString value, boolean defaultSelected, boolean selected)]
<pre class=idl>[NamedConstructor=<a href=#dom-option title=dom-option>Option</a>(optional DOMString text, optional DOMString value, optional boolean defaultSelected, optional boolean selected)]
interface <dfn id=htmloptionelement>HTMLOptionElement</dfn> : <a href=#htmlelement>HTMLElement</a> {
attribute boolean <a href=#dom-option-disabled title=dom-option-disabled>disabled</a>;
readonly attribute <a href=#htmlformelement>HTMLFormElement</a>? <a href=#dom-option-form title=dom-option-form>form</a>;
readonly attribute long <a href=#dom-option-index title=dom-option-index>index</a>;
};</pre>
</dd>
</dl><!--TOPIC:HTML--><p>The <code><a href=#the-option-element>option</a></code> element <a href=#represents>represents</a> an option
</dl><!--TOPIC:HTML--><!--CLEANUP--><p>The <code><a href=#the-option-element>option</a></code> element <a href=#represents>represents</a> an option
in a <code><a href=#the-select-element>select</a></code> element or as part of a list of suggestions
in a <code><a href=#the-datalist-element>datalist</a></code> element.</p>

<a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must
be set to true.</p>

<p class=note>The <code title=dom-option-tvd><a href=#dom-option-tvd>Option()</a></code>
constructor with three or fewer arguments overrides the initial
<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 argument is true (implying that a
<code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute is to
attribute must return the same value as the <code title=dom-fae-form><a href=#dom-fae-form>form</a></code> IDL attribute
on that <code><a href=#the-select-element>select</a></code> element. Otherwise, it must return null.</p>

<p>Several constructors are provided for creating <code><a href=#htmloptionelement>HTMLOptionElement</a></code> objects (in
addition to the factory methods from DOM such as <code title="">createElement()</code>): <dfn id=dom-option title=dom-option><code>Option()</code></dfn>, <dfn id=dom-option-t title=dom-option-t><code>Option(<var title="">text</var>)</code></dfn>, <dfn id=dom-option-tv title=dom-option-tv><code>Option(<var title="">text</var>, <var title="">value</var>)</code></dfn>, <dfn id=dom-option-tvd title=dom-option-tvd><code>Option(<var title="">text</var>, <var title="">value</var>, <var title="">defaultSelected</var>)</code></dfn>, and <dfn id=dom-option-tvds title=dom-option-tvds><code>Option(<var title="">text</var>, <var title="">value</var>, <var title="">defaultSelected</var>, <var title="">selected</var>)</code></dfn>. When invoked as constructors, these must return a new
<code><a href=#htmloptionelement>HTMLOptionElement</a></code> object (a new <code><a href=#the-option-element>option</a></code> element). If the <var title="">text</var> argument is present, the new object must have as its only child a
<code><a href=#text>Text</a></code> node whose data is the value of that argument. If the <var title="">value</var>
<!--CLEANUP-->
<p>A constructor is provided for creating <code><a href=#htmloptionelement>HTMLOptionElement</a></code> objects (in
addition to the factory methods from DOM such as <code title="">createElement()</code>):
<dfn id=dom-option title=dom-option><code>Option(<var title="">text</var>, <var title="">value</var>, <var title="">defaultSelected</var>, <var title="">selected</var>)</code></dfn>. When invoked as a constructor, it must return a new
<code><a href=#htmloptionelement>HTMLOptionElement</a></code> object (a new <code><a href=#the-option-element>option</a></code> element).
If the first argument is not the empty string, the new object must have as its only child a
<code><a href=#text>Text</a></code> node whose data is the value of that argument. Otherwise, it must have no children. If the <var title="">value</var>
argument is present, the new object must have a <code title=attr-option-value><a href=#attr-option-value>value</a></code>
attribute set with the value of the argument as its value. If the <var title="">defaultSelected</var> argument is present and true, the new object must have a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute set with no value. If the <var title="">selected</var> argument is present and true, the new object must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true; otherwise the fourth argument
is absent or false, and the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be
set to false, even if the <var title="">defaultSelected</var> argument is present and true. The
attribute set with the value of the argument as its value. If the <var title="">defaultSelected</var> argument is true, the new object must have a <code title=attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute set with no value. If the <var title="">selected</var> argument is true, the new object must have its <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> set to true; otherwise
the <a href=#concept-option-selectedness title=concept-option-selectedness>selectedness</a> must be
set to false, even if the <var title="">defaultSelected</var> argument is true. The
element's document must be the <a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>
of the <code><a href=#window>Window</a></code> object on which the interface object of the invoked constructor is
found.</p>


<h3 id=disk-space-0><span class=secno>11.3 </span>Disk space</h3>
<!--CLEANUP-->

<p>User agents should limit the total amount of space allowed for
storage areas.</p>
storage areas, because hostile authors could otherwise use this feature to exhaust the user's available disk space.</p>

<p>User agents should guard against sites storing data under their
origin's other affiliated sites, e.g. storing up to the limit in

0 comments on commit 9e0c937

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