<?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>12111</bug_id>
          
          <creation_ts>2011-02-17 15:17:57 +0000</creation_ts>
          <short_desc>spec for Storage object getItem(key) method does not match implementation behavior</short_desc>
          <delta_ts>2011-08-04 06:50:58 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>Web Storage (editor: Ian Hickson)</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael[tm] Smith">mike</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>adrianba</cc>
    
    <cc>annevk</cc>
    
    <cc>ap</cc>
    
    <cc>art.barstow</cc>
    
    <cc>ayg</cc>
    
    <cc>ian</cc>
    
    <cc>jorlow</cc>
    
    <cc>me</cc>
    
    <cc>mike</cc>
    
    <cc>plh</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>45772</commentid>
    <comment_count>0</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-02-17 15:17:57 +0000</bug_when>
    <thetext>http://dev.w3.org/html5/webstorage/#dom-storage-getitem says that &quot;The getItem(key) method must return a structured clone of the current value associated with the given key.&quot; but all browsers I&apos;ve tested return a string representation of the value instead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49023</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-06-01 17:39:04 +0000</bug_when>
    <thetext>This is just because the spec added this feature after the last round of implementations, but I&apos;ll mark this REMIND so I can look into it again in a few months and see where we stand.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49026</commentid>
    <comment_count>2</comment_count>
    <who name="Philippe Le Hegaret">plh</who>
    <bug_when>2011-06-01 18:12:35 +0000</bug_when>
    <thetext>A spec that does not match implementation behavior doesn&apos;t seem useful to me. Is there any reason to think that the implementations will change?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49033</commentid>
    <comment_count>3</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-06-01 20:19:01 +0000</bug_when>
    <thetext>I seriously doubt the specced behavior is web-compatible.  For instance, I myself just discovered this when trying to store booleans in localStorage, and worked around it by testing localStorage[&quot;foo&quot;] != &quot;false&quot;.  If localStorage[&quot;foo&quot;] = false suddenly actually sets it to false instead of &quot;false&quot;, this will break.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49056</commentid>
    <comment_count>4</comment_count>
    <who name="Arthur Barstow">art.barstow</who>
    <bug_when>2011-06-02 11:30:08 +0000</bug_when>
    <thetext>Aryeh, PLH - please make a concrete proposal (e.g. diff) that addresses your comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49057</commentid>
    <comment_count>5</comment_count>
    <who name="Philippe Le Hegaret">plh</who>
    <bug_when>2011-06-02 12:31:42 +0000</bug_when>
    <thetext>here is how the change should look like I think:

[[

interface Storage {
  [...]
  getter DOMString getItem(in DOMString key);
  setter creator void setItem(in DOMString key, in DOMString value);
  [...]
};

[...]

The getItem(key) method must return the current value associated with the given key. If the given key does not exist in the list associated with the object then this method must return null.

The setItem(key, value) method must set the value of a given key. If this raises an exception, then the exception must be thrown and the previous value associated with the given key is left unchanged.

]]

For forward compatibility purposes, I would not change the types of oldValue and newValue in the StorageEvent interface. In practice, those will be DOMString since that&apos;s the only thing one can store, but this could change in the future if we add a getValue and a setValue methods to the Storage interface with the type any.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49077</commentid>
    <comment_count>6</comment_count>
    <who name="Kyle Huey">me</who>
    <bug_when>2011-06-02 20:55:16 +0000</bug_when>
    <thetext>I talked with some other folks at Mozilla (Jonas Sicking and Ben Turner) about this and the general feeling seems to be that we&apos;re not particularly interested in implementing structured clones for localStorage values.  In addition to the web compat concerns, improving localStorage doesn&apos;t seem to be a good investment of time and resources, and runs the risk of encouraging more developers to use an API we&apos;d rather they didn&apos;t.

The isn&apos;t an official statement that we won&apos;t implement it (it&apos;s still open in our bug tracker at https://bugzilla.mozilla.org/show_bug.cgi?id=538142), and some other Mozilla people might disagree with me here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49142</commentid>
    <comment_count>7</comment_count>
    <who name="Jeremy Orlow">jorlow</who>
    <bug_when>2011-06-03 08:47:14 +0000</bug_when>
    <thetext>Kyle&apos;s comment also applies to Chromium.  (Including the fact that some folks may disagree, but I believe it&apos;s the predominate opinion of the developers working on it.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49165</commentid>
    <comment_count>8</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-06-03 17:12:44 +0000</bug_when>
    <thetext>I don&apos;t think that it matters too much whether developers manually serialize to JSON or the engine does that for them.

Having engine help would be good for consistency of the platform, as you should be able to assign persistent properties to localStorage and sessionStorage objects exactly like you do it for any JavaScript object. There is no technical reason to require the quirk of only allowing string properties, and I would personally like to have arbitrary properties implemented in WebKit eventually.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49202</commentid>
    <comment_count>9</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-06-05 18:20:19 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; I talked with some other folks at Mozilla (Jonas Sicking and Ben Turner) about
&gt; this and the general feeling seems to be that we&apos;re not particularly interested
&gt; in implementing structured clones for localStorage values.  In addition to the
&gt; web compat concerns, improving localStorage doesn&apos;t seem to be a good
&gt; investment of time and resources, and runs the risk of encouraging more
&gt; developers to use an API we&apos;d rather they didn&apos;t.

What should they use instead?  localStorage serves a very useful purpose as a simple persistent key-value store.  If it has problems, like locking or synchronousness, we need to either fix them or come up with a tenable replacement.  The only one I&apos;m aware of in the works is IDB, which doesn&apos;t even come close to being simple enough to be a localStorage replacement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49203</commentid>
    <comment_count>10</comment_count>
    <who name="Jeremy Orlow">jorlow</who>
    <bug_when>2011-06-05 18:35:49 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; (In reply to comment #6)
&gt; &gt; I talked with some other folks at Mozilla (Jonas Sicking and Ben Turner) about
&gt; &gt; this and the general feeling seems to be that we&apos;re not particularly interested
&gt; &gt; in implementing structured clones for localStorage values.  In addition to the
&gt; &gt; web compat concerns, improving localStorage doesn&apos;t seem to be a good
&gt; &gt; investment of time and resources, and runs the risk of encouraging more
&gt; &gt; developers to use an API we&apos;d rather they didn&apos;t.
&gt; 
&gt; What should they use instead?  localStorage serves a very useful purpose as a
&gt; simple persistent key-value store.  If it has problems, like locking or
&gt; synchronousness, we need to either fix them or come up with a tenable
&gt; replacement.  The only one I&apos;m aware of in the works is IDB, which doesn&apos;t even
&gt; come close to being simple enough to be a localStorage replacement.

Fixing local storage has been discussed ad nauseum. It can only be done with major backwards incompatible changes. We&apos;ve also talked about creating a new API and the sentiment is that we already have 3. At this point, more churn is probably not the right answer. Getting one API (IndexedDB) right, letting library developers (like lawnchair) fill in the gaps in the mean time, and making an educated decision in the future seems like a much better answer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49223</commentid>
    <comment_count>11</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-06-06 19:25:53 +0000</bug_when>
    <thetext>(In reply to comment #10)
&gt; Fixing local storage has been discussed ad nauseum. It can only be done with
&gt; major backwards incompatible changes. We&apos;ve also talked about creating a new
&gt; API and the sentiment is that we already have 3. At this point, more churn is
&gt; probably not the right answer. Getting one API (IndexedDB) right, letting
&gt; library developers (like lawnchair) fill in the gaps in the mean time, and
&gt; making an educated decision in the future seems like a much better answer.

I agree. This was raised back in November after TPAC:
http://lists.w3.org/Archives/Public/public-webapps/2010OctDec/0773.html
http://lists.w3.org/Archives/Public/public-webapps/2010OctDec/0798.html

Our plans have not changed: We have no plans to change the behaviour of Web Storage in IE to support structured clones. We believe IndexedDB represents a better mechanism for storing structured data in the Web Platform.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49912</commentid>
    <comment_count>12</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-06-20 10:44:01 +0000</bug_when>
    <thetext>I was asked to state Opera&apos;s position here. We do not feel strongly either way. If we indeed want people to move away from this API it would probably be better to keep it string-based so no extra implementation cycles are needed for a feature that is to be avoided.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49915</commentid>
    <comment_count>13</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-06-20 14:24:52 +0000</bug_when>
    <thetext>What&apos;s Opera&apos;s position on the compat implications?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49916</commentid>
    <comment_count>14</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-06-20 14:28:18 +0000</bug_when>
    <thetext>Making that transition is doable probably, but it is unlikely we will get that far seeing that no implementor apart from ap is really interested.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54148</commentid>
    <comment_count>15</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-04 06:50:44 +0000</bug_when>
    <thetext>Since browser vendors are no longer interested in using Web Storage for structured data, I&apos;ve moved the spec back to just strings.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54149</commentid>
    <comment_count>16</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-08-04 06:50:58 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r6364.
Check-in comment: Remove the structed data support from Web Storage.
http://html5.org/tools/web-apps-tracker?from=6363&amp;to=6364</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>