<?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>20553</bug_id>
          
          <creation_ts>2013-01-02 22:47:13 +0000</creation_ts>
          <short_desc>HTMLOptionsCollection.add() method throws in most browsers for out of range values</short_desc>
          <delta_ts>2013-03-06 22:58:45 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#htmloptionscollection-0</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>erik.arvidsson</cc>
    
    <cc>ian</cc>
    
    <cc>jsbell</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>80856</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-01-02 22:47:13 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html
Multipage: http://www.whatwg.org/C#htmloptionscollection-0
Complete: http://www.whatwg.org/c#htmloptionscollection-0

Comment:
The add() method throws in the majority of browsers for a differing out of
range values. In Chrome/Safari/IE/Opera it throws for all of -2, NaN,
Infinity, -Infinity. In Firefox it only throws for +/- Infinity. Nothing
throws on -1 or on positive values out of range. Per WebIDL&apos;s ECMAScript
binding the conversion of non-finites to long should not throw unless
[EnforceRange] is specified. Throwing for &lt;-1 would require prose. It&apos;s
unclear that throwing at all is useful here, but I wanted to note current
browser behavior.

Posted from: 2620:0:1002:1005:ae16:2dff:fe07:52dc
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.45 Safari/537.17</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80857</commentid>
    <comment_count>1</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2013-01-02 22:51:10 +0000</bug_when>
    <thetext>Cleaned up the summary.

Repro code to try:

[1000, -1, -2, Infinity, -Infinity, NaN].forEach(function(x) { try { document.createElement(&apos;select&apos;).options.add(document.createElement(&apos;option&apos;), x); } catch (e) { console.log(x + &quot;: &quot; + e); } })

Relevant WebIDL number-&gt;long conversion spec:

http://dev.w3.org/2006/webapi/WebIDL/#es-long

... which would indicate, lacking an [EnforceRange] attribute, that non-finites should yield 0 and hence not throw.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84040</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-03-06 22:04:19 +0000</bug_when>
    <thetext>http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2134

Firefox exactly matches the spec today as far as I can tell. Since there&apos;s no compelling reason to do anything else, I&apos;ve left the spec as is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84055</commentid>
    <comment_count>3</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2013-03-06 22:58:45 +0000</bug_when>
    <thetext>SGTM. Looks like Firefox updated since I last checked.

I have a Chrome patch in progress that match that behavior.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>