<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>11887</bug_id>
          
          <creation_ts>2011-01-27 10:39:06 +0000</creation_ts>
          <short_desc>Remove useless input.valueAsNumber. Pretty much the same functionality can be achieved using parseFloat or parseInt</short_desc>
          <delta_ts>2011-08-04 05:12:35 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#common-input-element-apis</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>12220</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>adrianba</cc>
    
    <cc>ayg</cc>
    
    <cc>bugs</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>mounir</cc>
    
    <cc>pecoraro</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>shadow2531</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>44791</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-01-27 10:39:06 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html
Section: http://www.whatwg.org/specs/web-apps/current-work/#common-input-element-apis

Comment:
Remove useless input.valueAsNumber. Pretty much the same functionality can be
actieved using parseFloat or parseInt

Posted from: 80.220.69.171</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44807</commentid>
    <comment_count>1</comment_count>
    <who name="Joseph Pecoraro">pecoraro</who>
    <bug_when>2011-01-27 18:57:41 +0000</bug_when>
    <thetext>input.valueAsNumber is useful for date and range input types. It isn&apos;t even allowed on text input types. See the table at:
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#the-input-element</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44886</commentid>
    <comment_count>2</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-01-30 01:45:23 +0000</bug_when>
    <thetext>Some input type likes type=range store the value internally as a number. Converting to a string for .value and then back to a number in script is a waste. valueAsNumber is useful to avoid this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44890</commentid>
    <comment_count>3</comment_count>
    <who name="Mounir Lamouri">mounir</who>
    <bug_when>2011-01-30 15:01:21 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; input.valueAsNumber is useful for date and range input types. It isn&apos;t even
&gt; allowed on text input types. See the table at:
&gt; http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#the-input-element

For range and number, |input.valueAsNumber| is equivalent to |parseFloat(input.value)|.
For date related types, |input.valueAsNumber| is equivalent to |input.valueAsDate.milliseconds|.
So, it&apos;s not really useful, it&apos;s only shorter (in term of characters).
In addition, I think the way .valueAsNumber behaves is really weird: returning the number of milliseconds from the UNIX epoch for date related types isn&apos;t intuitive.

(In reply to comment #2)
&gt; Some input type likes type=range store the value internally as a number.
&gt; Converting to a string for .value and then back to a number in script is a
&gt; waste. valueAsNumber is useful to avoid this.

According to the specs: &quot;The input element [in the Range state] represents a control for setting the element&apos;s value to a string representing a number.&quot;. It&apos;s the same for the Number state. And according to the specs you have to parse the value to a floating number when .valueAsNumber is called.
Though, I can understand that implementation could try to optimize .valueAsNumber by storing the value as a number but I don&apos;t think it worths keeping this method.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>44892</commentid>
    <comment_count>4</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-01-30 17:16:51 +0000</bug_when>
    <thetext>From API usage point of few the fact that some 
implementation may store the value as number doesn&apos;t really matter.
JS developers do know parseInt and parseFloat. Is there any reason why
they should use valueAsNumber?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45794</commentid>
    <comment_count>5</comment_count>
    <who name="Mounir Lamouri">mounir</who>
    <bug_when>2011-02-18 11:56:36 +0000</bug_when>
    <thetext>I&apos;ve actually found one situation where .valueAsNumber and parseFloat() would differ: if .value begins with a valid number which is followed by a string.
For example: &quot;42 foo&quot;; parseFloat() will return 42 and .valueAsNumber NaN.

That might be a good reason to keep .valueAsNumber I think.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45795</commentid>
    <comment_count>6</comment_count>
    <who name="Mounir Lamouri">mounir</who>
    <bug_when>2011-02-18 12:07:00 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; I&apos;ve actually found one situation where .valueAsNumber and parseFloat() would
&gt; differ: if .value begins with a valid number which is followed by a string.
&gt; For example: &quot;42 foo&quot;; parseFloat() will return 42 and .valueAsNumber NaN.
&gt; 
&gt; That might be a good reason to keep .valueAsNumber I think.

Actually, when valueAsNumber is available, value can&apos;t contain something else than a number so my previous comment doesn&apos;t apply...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46099</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-02-28 20:01:43 +0000</bug_when>
    <thetext>valueAsNumber was really just added for completeness after we added valueAsDate, IIRC. I don&apos;t mind removing it if people don&apos;t want to implement it. As the comments above say, it&apos;s purely an authoring convenience, it doesn&apos;t provide anything that can&apos;t be obtained in another way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46105</commentid>
    <comment_count>8</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-02-28 21:04:55 +0000</bug_when>
    <thetext>OK, so let&apos;s remove it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46178</commentid>
    <comment_count>9</comment_count>
    <who name="Mounir Lamouri">mounir</who>
    <bug_when>2011-03-02 17:05:53 +0000</bug_when>
    <thetext>It seems like parsing a floating point number in HTML and in Javascript specifications might differ. I&apos;ve open bug 12220 about that. I guess we should make sure it&apos;s fixed before removing valueAsNumber.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46185</commentid>
    <comment_count>10</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-03-02 17:41:44 +0000</bug_when>
    <thetext>In our prototyping we&apos;ve found the valueAsNumber concept is a useful convenience API that avoids a round-trip through a string. It&apos;s not hard to implement and since almost every use case where valueAsNumber is valid involves dealing with the value as a number why not keep it? It makes JavaScript code more readable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46186</commentid>
    <comment_count>11</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-03-02 17:45:12 +0000</bug_when>
    <thetext>How makes adding yet another method to DOM/JS the code more readable?
And actually, because of bug 12220, valueAsNumber works currently
rather strangely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46187</commentid>
    <comment_count>12</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-03-02 17:46:57 +0000</bug_when>
    <thetext>It&apos;s more readable because it&apos;s just a property access with a name that indicates what is happening.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48104</commentid>
    <comment_count>13</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-05-05 21:23:07 +0000</bug_when>
    <thetext>Right now Opera and WebKit support it, and IE and Firefox don&apos;t, but Microsoft is arguing in favour. This to me seems to suggest we should keep it, even though it&apos;s very much a convenience method and doesn&apos;t really provide anything truly novel. I&apos;m not closing this bug yet, though; if the people who want for us to drop this can convince the vendors who have shipped with it to remove it then I&apos;d be happy to remove it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48382</commentid>
    <comment_count>14</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-05-09 21:49:03 +0000</bug_when>
    <thetext>Came across an interesting example of the convenience for this recently: changing the value of a range control by a certain known delta:

   input.valueAsNumber += delta;

The alternatives are a bit of a pain:

   input.value = parseFloat(input.value) + delta;

   if (delta &gt; 0)
     input.stepUp(delta/parseFloat(input.step));
   else
     input.stepDown(delta/parseFloat(input.step));</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52133</commentid>
    <comment_count>15</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-03 07:21:14 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: no spec change
Rationale: see last two comments</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53310</commentid>
    <comment_count>16</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:12:35 +0000</bug_when>
    <thetext>mass-move component to LC1</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>