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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>14325</bug_id>
          
          <creation_ts>2007-06-22 17:47:57 -0700</creation_ts>
          <short_desc>Using built-in type Constructor objects as keys fails</short_desc>
          <delta_ts>2007-06-22 18:27:49 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Adam Winer">awiner</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>6655</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Winer">awiner</who>
    <bug_when>2007-06-22 17:47:57 -0700</bug_when>
    <thetext>Run the following page.  In FF 2.0 and IE 7.0, you see
&quot;n b s d a m&quot;.  In Safari, you just see &quot;m&quot;!   Somehow,
all of these constructors are considered the same key
within an Object - this despite String == Object being
false.

Repros on both MacOS 419.3 and Windows 522.13.1.

&lt;html&gt;
&lt;head&gt;
&lt;script&gt;
var typeMap = new Object();
typeMap[Number] = &quot;n&quot;;
typeMap[Boolean] = &quot;b&quot;;
typeMap[String] = &quot;s&quot;;
typeMap[Date] = &quot;d&quot;;
typeMap[Array] = &quot;a&quot;;
typeMap[Object] = &quot;m&quot;;

var str = &quot;&quot;;
for (var i in typeMap)
{
  str += typeMap[i] + &quot; &quot;;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id =&apos;someId&apos; onclick=&quot;testHtml()&quot;&gt;Hi&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6653</commentid>
    <comment_count>1</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2007-06-22 18:27:49 -0700</bug_when>
    <thetext>This is a coincidental side-effect of the fact that Firefox and IE convert these objects to unique strings.

Generally, JavaScript does not support using an object as a key. It uses strings as keys.

The following fails in the same way in Firefox, even though each key is a distinct object:

typeMap[new Object] = &quot;n&quot;;
typeMap[new Object] = &quot;b&quot;;
typeMap[new Object] = &quot;s&quot;;
typeMap[new Object] = &quot;d&quot;;
typeMap[new Object] = &quot;a&quot;;
typeMap[new Object] = &quot;m&quot;;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>