Short URL: http://html5.org/r/2243
| SVN | Bug | Comment | Time (UTC) |
|---|---|---|---|
| 2243 | WF2: Revamp min/max/step, valueAsDate, valueAsNumber, stepUp, stepDown, and type=datetime. | 2008-09-30 03:14 |
Index: source
===================================================================
--- source (revision 2242)
+++ source (revision 2243)
@@ -1306,8 +1306,8 @@
<p>The <dfn>rules for parsing floating point number values</dfn> are
as given in the following algorithm. As with the previous
algorithms, when this one is invoked, the steps must be followed in
- the order given, aborting at the first step that returns a
- value. This algorithm will either return a number or an
+ the order given, aborting at the first step that returns
+ something. This algorithm will either return a number or an
error. Leading spaces are ignored. Trailing spaces and garbage
characters are ignored.</p>
@@ -1365,8 +1365,7 @@
title="">value</var> by that integer.</p></li>
<li>If <var title="">position</var> is past the end of <var
- title="">input</var>, return <var title="">value</var> and abort
- these steps.</li>
+ title="">input</var>, return <var title="">value</var>.</li>
<li><p>If the character indicated by <var title="">position</var>
is a U+002E FULL STOP ("."), run these substeps:</p>
@@ -1379,8 +1378,7 @@
<li><p>If <var title="">position</var> is past the end of <var
title="">input</var>, or if the character indicated by <var
title="">position</var> is not one of U+0030 DIGIT ZERO (0)
- .. U+0039 DIGIT NINE (9), then return <var title="">value</var>
- and abort these steps.</li>
+ .. U+0039 DIGIT NINE (9), then return <var title="">value</var>.</li>
<li><p><i>Fraction loop</i>: Multiply <var title="">divisor</var>
by ten.</p></li>
@@ -1393,8 +1391,7 @@
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var
- title="">input</var>, then return <var title="">value</var> and
- abort these steps.</li>
+ title="">input</var>, then return <var title="">value</var>.</li>
<li><p>If the character indicated by <var title="">position</var>
is one of U+0030 DIGIT ZERO (0) .. U+0039 DIGIT NINE (9), return
@@ -1415,8 +1412,7 @@
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var
- title="">input</var>, then return <var title="">value</var> and
- abort these steps.</li>
+ title="">input</var>, then return <var title="">value</var>.</li>
<li>
@@ -1431,8 +1427,8 @@
character.</li>
<li><p>If <var title="">position</var> is past the end of <var
- title="">input</var>, then return <var title="">value</var> and
- abort these steps.</li>
+ title="">input</var>, then return <var
+ title="">value</var>.</li>
</ol>
@@ -1440,7 +1436,7 @@
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0030 DIGIT ZERO (0) .. U+0039 DIGIT NINE (9),
- then return <var title="">value</var> and abort these steps.</li>
+ then return <var title="">value</var>.</li>
<li><p><span>Collect a sequence of characters</span> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
@@ -26142,7 +26138,22 @@
<p>Each <code>input</code> element has a <span
title="concept-fe-value">value</span>, which is exposed by the <code
- title="dom-input-value">value</code> DOM attribute.</p>
+ title="dom-input-value">value</code> DOM attribute. Some states
+ define an <dfn title="concept-input-value-string-number">algorithm
+ to convert a string to a number</dfn>, an <dfn
+ title="concept-input-value-number-string">algorithm to convert a
+ number to a string</dfn>, an <dfn
+ title="concept-input-value-string-date">algorithm to convert a
+ string to a <code>Date</code> object</dfn>, and an <dfn
+ title="concept-input-value-date-string">algorithm to convert a
+ <code>Date</code> object to a string</dfn>, which are used by
+ <code title="attr-input-max">max</code>,
+ <code title="attr-input-min">min</code>,
+ <code title="attr-input-step">step</code>,
+ <code title="dom-input-valueAsDate">valueAsDate</code>,
+ <code title="dom-input-valueAsNumber">valueAsNumber</code>,
+ <code title="dom-input-stepUp">stepUp()</code>, and
+ <code title="dom-input-stepDown">stepDown()</code>.</p>
<p>Each <code>input</code> element has a boolean <dfn
title="concept-input-mutability">mutability flag</dfn>. When it is
@@ -26533,62 +26544,79 @@
of the element is not a <span>valid UTC date and time</span>, then
set it to the empty string instead.</p>
- <p>The <dfn title="concept-input-value-datetime">selected UTC date
- and time</dfn> is the result of <span title="parse a UTC date and
- time">parsing a UTC date and time</span> from the element's <span
- title="concept-fe-value">value</span>, unless that fails, in which
- case there is no <span title="concept-input-value-datetime">selected
- UTC date and time</span>.</p>
+ <p><strong>The <span
+ title="concept-input-value-string-number">algorithm to convert a
+ string to a number</span>, given a string <var
+ title="">input</var></strong>, is as follows:</p>
- <p class="big-issue"><strong>The <span><code
- title="dom-input-valueAsDate">valueAsDate</code> setter
- algorithm</span> is as follows:</strong> ...</p>
+ <ol>
- <p class="big-issue"><strong>The <span><code
- title="dom-input-valueAsNumber">valueAsNumber</code> setter
- algorithm</span> is as follows:</strong> ...</p>
+ <li><p><span>Parse a UTC date and time</span> from <var
+ title="">input</var>.</p></li>
- <p>The <code title="attr-input-min">min</code> attribute, if
- specified, must have a value that is a <span>valid UTC date and
- time</span>. The <dfn title="concept-input-min-datetime">minimum UTC
- date and time</dfn> is the result of <span title="parse a UTC date
- and time">parsing a UTC date and time</span> from the element's
- <code title="attr-input-min">min</code> attribute, unless that
- fails, in which case there is no <span
- title="concept-input-min-datetime">minimum UTC date and
- time</span>.</p>
+ <li><p>If that results in an error, return an error and abort these
+ steps.</p></li>
- <p><strong>Constraint validation:</strong> When there is both a
- <span title="concept-input-value-datetime">selected UTC date and
- time</span> and a <span title="concept-input-min-datetime">minimum
- UTC date and time</span>, if the former is earlier than the latter,
- the element is <span>suffering from an underflow</span>.</p>
+ <li><p>Otherwise, return the number of milliseconds elapsed from
+ midnight UTC on the morning of 1970-01-01 (the time represented by
+ the value "<code title="">1970-01-01T00:00:00.0Z</code>") to the
+ parsed date and time, ignoring leap seconds.</p></li>
- <p>The <code title="attr-input-max">max</code> attribute, if
+ </ol>
+
+ <p><strong>The <span
+ title="concept-input-value-number-string">algorithm to convert a
+ number to a string</span>, given a number <var
+ title="">input</var></strong>, consists of returning a <span>valid
+ UTC date and time</span> that represents the date and time in UTC
+ that is <var title="">input</var> milliseconds afer midnight UTC on
+ the morning of 1970-01-01 (the time represented by the value "<code
+ title="">1970-01-01T00:00:00.0Z</code>").</p>
+
+ <p><strong>The <span
+ title="concept-input-value-string-date">algorithm to convert a
+ string to a <code>Date</code> object</span>, given a string <var
+ title="">input</var></strong>, is as follows:</p>
+
+ <ol>
+
+ <li><p><span>Parse a UTC date and time</span> from <var
+ title="">input</var>.</p></li>
+
+ <li><p>If that results in an error, return an error and abort these
+ steps.</p></li>
+
+ <li><p>Otherwise, return a <code>Date</code> object representing
+ the parsed date and time.</p></li>
+
+ </ol>
+
+ <p><strong>The <span
+ title="concept-input-value-date-string">algorithm to convert a
+ <code>Date</code> object to a string</span>, given a
+ <code>Date</code> object <var title="">input</var></strong>,
+ consists of returning a <span>valid UTC date and time</span> that
+ represents the date and time in UTC that is represented by <var
+ title="">input</var>.</p>
+
+ <!-- MIN AND MAX: -->
+
+ <p>The <code title="attr-input-min">min</code> attribute, if
specified, must have a value that is a <span>valid UTC date and
- time</span>. The <dfn title="concept-input-max-datetime">maximum UTC
- date and time</dfn> is the result of <span title="parse a UTC date
- and time">parsing a UTC date and time</span> from the element's
- <code title="attr-input-max">max</code> attribute, unless that
- fails, in which case there is no <span
- title="concept-input-max-datetime">maximum UTC date and
+ time</span>. The <code title="attr-input-max">max</code> attribute,
+ if specified, must have a value that is a <span>valid UTC date and
time</span>.</p>
- <p><strong>Constraint validation:</strong> When there is both a
- <span title="concept-input-value-datetime">selected UTC date and
- time</span> and a <span title="concept-input-max-datetime">maximum
- UTC date and time</span>, if the former is later than the latter,
- the element is <span>suffering from an overflow</span>.</p>
+ <!-- STEP: -->
- <p class="big-issue">The <code title="attr-input-step">step</code>
- attribute, if specified, must have a value that is a ...</p>
+ <p>The <code title="attr-input-step">step</code> attribute is
+ expressed in seconds. The <span
+ title="concept-input-step-scale">step scale factor</span> is 1000
+ (which converts the seconds to milliseconds, as used in the other
+ algorithms). The <span title="concept-input-step-default">default
+ step</span> is 60 seconds.</p>
- <!-- values: positive non-zero floating point, or "any" -->
- <!-- units: seconds -->
- <!-- default: 60 -->
- <!-- zero point: min, or 1970-01-01T00:00:00.0Z -->
- <!-- allow rounding -->
- <!-- <span>suffering from a step mismatch</span> -->
+ <!-- XXX allow rounding -->
<p>The following common <code>input</code> element content
attributes, DOM attributes, and methods apply to the element:
@@ -26996,21 +27024,126 @@
- <h6>Other attributes</h6>
+ <h6>The <code title="attr-input-min">min</code> and <code
+ title="attr-input-max">max</code> attributes</h6>
<p>The <dfn title="attr-input-min"><code>min</code></dfn> and <dfn
- title="attr-input-max"><code>max</code></dfn> attributes define a
- range constraint on the value.</p>
+ title="attr-input-max"><code>max</code></dfn> attributes indicate
+ the allowed range of values for the element.</p>
+ <p>Their syntax is defined by the section that defines the <code
+ title="attr-input-type">type</code> attribute's current state.</p>
+
+ <p><strong>Constraint validation:</strong> When the element has a
+ <code title="attr-input-min">min</code> attribute, and the result of
+ applying the <span
+ title="concept-input-value-string-number">algorithm to convert a
+ string to a number</span> to the string given by the element's <span
+ title="concept-input-value">value</span> is a number, and the result
+ of applying the <span
+ title="concept-input-value-string-number">algorithm to convert a
+ string to a number</span> to the value of the <code
+ title="attr-input-min">min</code> attribute is also a number, and
+ the number obtained from the former is less than the number obtained
+ from the latter, the element is <span>suffering from an
+ underflow</span>.</p>
+
+ <p><strong>Constraint validation:</strong> When the element has a
+ <code title="attr-input-max">max</code> attribute, and the result of
+ applying the <span
+ title="concept-input-value-string-number">algorithm to convert a
+ string to a number</span> to the string given by the element's <span
+ title="concept-input-value">value</span> is a number, and the result
+ of applying the <span
+ title="concept-input-value-string-number">algorithm to convert a
+ string to a number</span> to the value of the <code
+ title="attr-input-max">max</code> attribute is also a number, and
+ the number obtained from the former is greater than the number
+ obtained from the latter, the element is <span>suffering from an
+ overflow</span>.</p>
+
+ <p>The <code title="attr-input-min">min</code> attribute also
+ defines the <span title="concept-input-min-zero">step
+ base</span>.</p>
+
+
+ <h6>The <code title="attr-input-step">step</code> attribute</h6>
+
<p>The <dfn title="attr-input-step"><code>step</code></dfn>
- attribute defines the increments between allowed values.</p>
+ attribute indicates the granularity that is expected (and required)
+ of the <span title="concept-input-value">value</span>, by limiting
+ the allowed values. The section that defines the <code
+ title="attr-input-type">type</code> attribute's current state also
+ defines the <dfn title="concept-input-step-default">default
+ step</dfn> and the <dfn title="concept-input-step-scale">step
+ scale factor</dfn>, which are used in processing the attribute as
+ described below.</p>
- <p>These attributes apply for a number of different states, but as
- their behavior varies from state to state, they are not defined here
- but instead in the states' own sections.</p>
+ <p>The <code title="attr-input-step">step</code> attribute, if
+ specified, must either have a value that is a <span>valid floating
+ point number</span> that <span title="rules for parsing floating
+ point number values">parses</span> to a number that is greater than
+ zero, or must have a value that is an <span>ASCII
+ case-insensitive</span> match for the string "<code
+ title="">any</code>".</p>
+ <p>The attribute provides the <dfn
+ title="concept-input-step">allowed value step</dfn> for the element,
+ as follows:</p>
+ <ol>
+ <li>If the attribute is absent, then the <span
+ title="concept-input-step">allowed value step</span> is the <span
+ title="concept-input-step-default">default step</span> multiplied
+ by the <span title="concept-input-step-scale">step scale
+ factor</span>.</li>
+
+ <li>Otherwise, if the attribute's value is an <span>ASCII
+ case-insensitive</span> match for the string "<code
+ title="">any</code>", then there is no <span
+ title="concept-input-step">allowed value step</span>.</li>
+
+ <li>Otherwise, if the <span>rules for parsing floating point number
+ values</span>, when they are applied to the attribute's value,
+ return an error, zero, or a number less than zero, then the <span
+ title="concept-input-step">allowed value step</span> is the <span
+ title="concept-input-step-default">default step</span> multiplied
+ by the <span title="concept-input-step-scale">step scale
+ factor</span>.</li>
+
+ <li>Otherwise, the <span title="concept-input-step">allowed value
+ step</span> is the number returned by the <span>rules for parsing
+ floating point number values</span> when they are applied to the
+ attribute's value, multiplied by the <span
+ title="concept-input-step-scale">step scale factor</span>.</li>
+
+ </ol>
+
+ <p>The <dfn title="concept-input-min-zero">step base</dfn> is the
+ result of applying the <span
+ title="concept-input-value-string-number">algorithm to convert a
+ string to a number</span> to the value of the <code
+ title="attr-input-min">min</code> attribute, unless the element does
+ not have a <code title="attr-input-min">min</code> attribute
+ specified or the result of applying that algorithm is an error, in
+ which case the <span title="concept-input-min-zero">step base</span>
+ is zero.</p>
+
+ <p><strong>Constraint validation:</strong> When the element has an
+ <span title="concept-input-step">allowed value step</span>, and the
+ result of applying the <span
+ title="concept-input-value-string-number">algorithm to convert a
+ string to a number</span> to the string given by the element's <span
+ title="concept-input-value">value</span> is a number, and that
+ number subtracted from the <span title="concept-input-min-zero">step
+ base</span> is not an integral multiple of the <span
+ title="concept-input-step">allowed value step</span>, the element is
+ <span>suffering from a step mismatch</span>.</p>
+
+
+
+
<h5>Common <code>input</code> element APIs</h5>
<h6>Value manipulation</h6>
@@ -27035,59 +27168,109 @@
as a date.</p>
<p>On getting, if the <code
- title="dom-input-valueAsDate">valueAsDate</code> attribute applies,
- as defined for the <code>input</code> element's <code
+ title="dom-input-valueAsDate">valueAsDate</code> attribute does not
+ apply, as defined for the <code>input</code> element's <code
title="attr-input-type">type</code> attribute's current state, then
- run the <dfn><code title="dom-input-valueAsDate">valueAsDate</code>
- getter algorithm</dfn> defined for that state. Otherwise, return a
- Not-a-Number (NaN) value.</p>
+ return null. Otherwise, run the <dfn
+ title="concept-input-value-string-date">algorithm to convert a
+ string to a <code>Date</code> object</dfn> defined for that state;
+ if the algorithm returned a <code>Date</code> object, then return
+ it, otherwise, return null.</p>
<p>On setting, if the <code
- title="dom-input-valueAsDate">valueAsDate</code> attribute applies,
- as defined for the <code>input</code> element's <code
+ title="dom-input-valueAsDate">valueAsDate</code> attribute does not
+ apply, as defined for the <code>input</code> element's <code
title="attr-input-type">type</code> attribute's current state, then
- run the <dfn><code title="dom-input-valueAsDate">valueAsDate</code>
- setter algorithm</dfn> defined for that state. Otherwise, do
- nothing.</p>
+ throw an <code>INVALID_ACCESS_ERR</code> exception; otherwise, if
+ the new value is null, then set the <span
+ title="concept-input-value">value</span> of the element to the empty
+ string; otherwise, run the <dfn
+ title="concept-input-value-date-string">algorithm to convert a
+ <code>Date</code> object to a string</dfn>, as defined for that
+ state, on the new value, and set the <span
+ title="concept-input-value">value</span> of the element to resulting
+ string.</p>
<hr>
<p>The <dfn
title="dom-input-valueAsNumber"><code>valueAsNumber</code></dfn> DOM
- attribute represents the <span
- title="concept-fe-value">value</span> of the element, interpreted
- as a number.</p>
+ attribute represents the <span title="concept-fe-value">value</span>
+ of the element, interpreted as a number.</p>
<p>On getting, if the <code
- title="dom-input-valueAsNumber">valueAsNumber</code> attribute
- applies, as defined for the <code>input</code> element's <code
+ title="dom-input-valueAsNumber">valueAsNumber</code> attribute does
+ not apply, as defined for the <code>input</code> element's <code
title="attr-input-type">type</code> attribute's current state, then
- run the <dfn><code
- title="dom-input-valueAsNumber">valueAsNumber</code> getter
- algorithm</dfn> defined for that state. Otherwise, return the <span
- title="concept-fe-value">value</span> of the element, cast to the
- type of the DOM attribute.</p>
+ return a Not-a-Number (NaN) value. Otherwise, run the <dfn
+ title="concept-input-value-string-number">algorithm to convert a
+ string to a number</dfn> defined for that state; if the algorithm
+ returned a number, then return it, otherwise, return a Not-a-Number
+ (NaN) value.</p>
<p>On setting, if the <code
- title="dom-input-valueAsNumber">valueAsNumber</code> attribute
- applies, as defined for the <code>input</code> element's <code
+ title="dom-input-valueAsNumber">valueAsNumber</code> attribute does
+ not apply, as defined for the <code>input</code> element's <code
title="attr-input-type">type</code> attribute's current state, then
- run the <dfn><code
- title="dom-input-valueAsNumber">valueAsNumber</code> setter
- algorithm</dfn> defined for that state. Otherwise, the <span
- title="concept-fe-value">value</span> must be set to the shortest
- possible representation of the given value that is a <span>valid
- floating point number</span> in base ten.</p>
+ throw an <code>INVALID_ACCESS_ERR</code> exception; otherwise, run
+ the <dfn title="concept-input-value-number-string">algorithm to
+ convert a number to a string</dfn>, as defined for that state, on
+ the new value, and set the <span
+ title="concept-input-value">value</span> of the element to resulting
+ string.</p>
+ <hr>
+ <p>The <dfn title="dom-input-stepUp"><code>stepUp()</code></dfn> and
+ <dfn title="dom-input-stepDown"><code>stepDown()</code></dfn>
+ methods, when invoked, must run the following algorithm:</p>
+ <ol>
+
+ <li><p>If the <code title="dom-input-stepUp">stepUp()</code> and
+ <code title="dom-input-stepDown">stepDown()</code> methods do not
+ apply, as defined for the <code>input</code> element's <code
+ title="attr-input-type">type</code> attribute's current state, then
+ throw an <code>INVALID_ACCESS_ERR</code> exception, and abort these
+ steps.</p></li>
+
+ <li><p>If the element has no <span
+ title="concept-input-step">allowed value step</span>, then throw a
+ <code>INVALID_ACCESS_ERR</code> exception, and abort these
+ steps.</p></li>
+
+ <li><p>If applying the <span
+ title="concept-input-value-string-number">algorithm to convert a
+ string to a number</span> to the string given by the element's
+ <span title="concept-input-value">value</span> results in an error,
+ then throw an <code>INVALID_ACCESS_ERR</code> exception, and abort
+ these steps; otherwise, let <var title="">value</var> be the result
+ of that algorithm.</p></li>
+
+ <li><p>If the method invoked was the <code
+ title="dom-input-stepDown">stepDown()</code> method, negate <var
+ title="">value</var>.</p></li>
+
+ <li><p>Let <var title="">value</var> be the result of adding the
+ <span title="concept-input-step">allowed value step</span> to <var
+ title="">value</var>.</p></li>
+
+ <li><p>Run the <dfn
+ title="concept-input-value-number-string">algorithm to convert a
+ number to a string</dfn>, as defined for the <code>input</code>
+ element's <code title="attr-input-type">type</code> attribute's
+ current state, on <var title="">value</var>, and set the <span
+ title="concept-input-value">value</span> of the element to
+ resulting string.</p></li>
+
+ </ol>
+
+
<h6>Others...</h6>
<p class="big-issue">... <dfn title="dom-input-checked"><code>checked</code></dfn></p>
<p class="big-issue">... <dfn title="dom-input-list"><code>list</code></dfn></p>
<p class="big-issue">... <dfn title="dom-input-selectedOption"><code>selectedOption</code></dfn></p>
- <p class="big-issue">... <dfn title="dom-input-stepUp"><code>stepUp()</code></dfn></p>
- <p class="big-issue">... <dfn title="dom-input-stepDown"><code>stepDown()</code></dfn></p>