hixie: Make Storage support structured data, not just strings. (whatwg r3549)

hixie: Make Storage support structured data, not just strings. (whatwg
r3549)

http://dev.w3.org/cvsweb/html5/webstorage/Overview.html?r1=1.56&r2=1.57&f=h
http://html5.org/tools/web-apps-tracker?from=3548&to=3549

===================================================================
RCS file: /sources/public/html5/webstorage/Overview.html,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- Overview.html 16 Jul 2009 07:27:02 -0000 1.56
+++ Overview.html 6 Aug 2009 23:43:35 -0000 1.57
@@ -174,7 +174,7 @@
    <h1>Web Storage</h1>
    <!--ZZZ:-->
    <!--<h2 class="no-num no-toc">W3C Working Draft 23 April 2009</h2>-->
-   <h2 class="no-num no-toc" id="editor-s-draft-date-1-january-1970">Editor's Draft 16 July 2009</h2>
+   <h2 class="no-num no-toc" id="editor-s-draft-date-1-january-1970">Editor's Draft 6 August 2009</h2>
    <!--:ZZZ-->
    <dl><!-- ZZZ: update the month/day (twice), (un)comment out
     <dt>This Version:</dt>
@@ -241,7 +241,7 @@
   specification's progress along the W3C Recommendation track.
   <!--ZZZ:-->
   <!--This specification is the 23 April 2009 Working Draft.-->
-  This specification is the 16 July 2009 Editor's Draft.
+  This specification is the 6 August 2009 Editor's Draft.
   <!--:ZZZ-->
   </p><!-- required patent boilerplate --><p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5
   February 2004 W3C Patent Policy</a>. W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/42538/status" rel="disclosure">public list of
@@ -403,9 +403,9 @@
   the official term ECMAScript, since the term JavaScript is more
   widely known. <a href="#references">[ECMA262]</a><h2 id="storage"><span class="secno">4 </span>The API</h2><h3 id="the-storage-interface"><span class="secno">4.1 </span>The <code><a href="#storage-0">Storage</a></code> interface</h3><pre class="idl">interface <dfn id="storage-0">Storage</dfn> {
   readonly attribute unsigned long <a href="#dom-storage-length" title="dom-Storage-length">length</a>;
-  [IndexGetter] DOMString <a href="#dom-storage-key" title="dom-Storage-key">key</a>(in unsigned long index);
-  [NameGetter] DOMString <a href="#dom-storage-getitem" title="dom-Storage-getItem">getItem</a>(in DOMString key);
-  [NameSetter, NameCreator] void <a href="#dom-storage-setitem" title="dom-Storage-setItem">setItem</a>(in DOMString key, in DOMString data);
+  [IndexGetter] any <a href="#dom-storage-key" title="dom-Storage-key">key</a>(in unsigned long index);
+  [NameGetter] any <a href="#dom-storage-getitem" title="dom-Storage-getItem">getItem</a>(in DOMString key);
+  [NameSetter, NameCreator] void <a href="#dom-storage-setitem" title="dom-Storage-setItem">setItem</a>(in DOMString key, in any data);
   [NameDeleter] void <a href="#dom-storage-removeitem" title="dom-Storage-removeItem">removeItem</a>(in DOMString key);
   void <a href="#dom-storage-clear" title="dom-Storage-clear">clear</a>();
 };</pre><!-- v2 ideas:
@@ -415,10 +415,10 @@
        - which page was the last to modify the key
     [-Mihai Sucan]
   --><p>Each <code><a href="#storage-0">Storage</a></code> object provides access to a list of
-  key/value pairs, which are sometimes called items. Keys and values
-  are strings. Any string (including the empty string) is a valid
-  key.<p class="note">To store more structured data, authors may consider
-  using the <a href="#sql">SQL interfaces</a> instead.<p>Each <code><a href="#storage-0">Storage</a></code> object is associated with a list of
+  key/value pairs, which are sometimes called items. Keys are
+  strings. Any string (including the empty string) is a valid
+  key. Values can be any data type supported by the <span>structured
+  clone</span> algorithm.<p>Each <code><a href="#storage-0">Storage</a></code> object is associated with a list of
   key/value pairs when it is created, as defined in the sections on
   the <code title="dom-sessionStorage"><a href="#dom-sessionstorage">sessionStorage</a></code> and <code title="dom-localStorage"><a href="#dom-localstorage">localStorage</a></code> attributes. Multiple
   separate objects implementing the <code><a href="#storage-0">Storage</a></code> interface can
@@ -441,15 +441,25 @@
   unsigned]--> greater than or equal to the number of key/value pairs
   in the object, then this method must return null.<p>The <span>names of the supported named properties</span> on a
   <code><a href="#storage-0">Storage</a></code> object are the keys of each key/value pair
-  currently present in the list associated with the object.<p>The <dfn id="dom-storage-getitem" title="dom-Storage-getItem"><code>getItem(<var title="">key</var>)</code></dfn> method must return the current
-  value associated with the given <var title="">key</var>. If the
-  given <var title="">key</var> does not exist in the list associated
-  with the object then this method must return null.<p>The <dfn id="dom-storage-setitem" title="dom-Storage-setItem"><code>setItem(<var title="">key</var>, <var title="">value</var>)</code></dfn> method
-  must first check if a key/value pair with the given <var title="">key</var> already exists in the list associated with the
-  object.<p>If it does not, then a new key/value pair must be added to the
-  list, with the given <var title="">key</var> and <var title="">value</var>.<p>If the given <var title="">key</var> <em>does</em> exist in the
-  list, then it must have its value updated to the value given in the
-  <var title="">value</var> argument.<p>If it couldn't set the new value, the method must raise an
+  currently present in the list associated with the object.<p>The <dfn id="dom-storage-getitem" title="dom-Storage-getItem"><code>getItem(<var title="">key</var>)</code></dfn> method must return a
+  <span>structured clone</span> of the current value associated with
+  the given <var title="">key</var>. If the given <var title="">key</var> does not exist in the list associated with the
+  object then this method must return null.<p>The <dfn id="dom-storage-setitem" title="dom-Storage-setItem"><code>setItem(<var title="">key</var>, <var title="">value</var>)</code></dfn> method
+  must first create a <span>structured clone</span> of the given <var title="">value</var>. If this raises an exception, then the
+  exception must be thrown and the list associated with the object is
+  left unchanged. If constructing the stuctured clone would involve
+  constructing a new <code>ImageData</code> object, then throw a
+  <code>NOT_SUPPORTED_ERR</code> exception instead.</p><!-- ImageData isn't supported because reading such objects is
+  synchronous, and getData() is synchronous, and therefore if the
+  stored data is in deep storage, it would be very painful to have a
+  script grab the value and immediately try to read the image
+  data. --><p>Otherwise, the user agent must then check if a key/value pair
+  with the given <var title="">key</var> already exists in the list
+  associated with the object.<p>If it does not, then a new key/value pair must be added to the
+  list, with the given <var title="">key</var> and with its value set
+  to the newly obtained clone of <var title="">value</var>.<p>If the given <var title="">key</var> <em>does</em> exist in the
+  list, then it must have its value updated to the newly obtained
+  clone of <var title="">value</var>.<p>If it couldn't set the new value, the method must raise an
   <code>QUOTA_EXCEEDED_ERR</code> exception. (Setting could fail if,
   e.g., the user has disabled storage for the site, or if the quota
   has been exceeded.)<p>The <dfn id="dom-storage-removeitem" title="dom-Storage-removeItem"><code>removeItem(<var title="">key</var>)</code></dfn> method must cause the key/value
@@ -556,14 +566,13 @@
   not <span>fully active</span>, but events fired on those are ignored
   by the <span>event loop</span> until the <code>Document</code>
   becomes <span>fully active</span> again.<p>The <span>task source</span> for this task is the <span>DOM
-  manipulation task source</span>.<p>If the event is being fired due to an invocation of the
-  <code title="dom-Storage-setItem"><a href="#dom-storage-setitem">setItem()</a></code> or <code title="dom-Storage-removeItem"><a href="#dom-storage-removeitem">removeItem()</a></code> methods, the
+  manipulation task source</span>.<p>If the event is being fired due to an invocation of the <code title="dom-Storage-setItem"><a href="#dom-storage-setitem">setItem()</a></code> or <code title="dom-Storage-removeItem"><a href="#dom-storage-removeitem">removeItem()</a></code> methods, the
   event must have its <code title="dom-StorageEvent-key"><a href="#dom-storageevent-key">key</a></code>
-  attribute set to the name of the key in question, its <code title="dom-StorageEvent-oldValue"><a href="#dom-storageevent-oldvalue">oldValue</a></code> attribute set to
-  the old value of the key in question, or null if the key is newly
-  added, and its <code title="dom-StorageEvent-newValue"><a href="#dom-storageevent-newvalue">newValue</a></code>
-  attribute set to the new value of the key in question, or null if
-  the key was removed.<p>Otherwise, if the event is being fired due to an invocation of
+  attribute set to the name of the key in question, its <code title="dom-StorageEvent-oldValue"><a href="#dom-storageevent-oldvalue">oldValue</a></code> attribute set to a
+  <span>structured clone</span> of the old value of the key in
+  question, or null if the key is newly added, and its <code title="dom-StorageEvent-newValue"><a href="#dom-storageevent-newvalue">newValue</a></code> attribute set to a
+  <span>structured clone</span> of the new value of the key in
+  question, or null if the key was removed.<p>Otherwise, if the event is being fired due to an invocation of
   the <code title="dom-Storage-clear"><a href="#dom-storage-clear">clear()</a></code> method, the event
   must have its <code title="dom-StorageEvent-key"><a href="#dom-storageevent-key">key</a></code>, <code title="dom-StorageEvent-oldValue"><a href="#dom-storageevent-oldvalue">oldValue</a></code>, and <code title="dom-StorageEvent-newValue"><a href="#dom-storageevent-newvalue">newValue</a></code> attributes set to
   null.<p>In addition, the event must have its <code title="dom-StorageEvent-url"><a href="#dom-storageevent-url">url</a></code> attribute set to <span title="the document's address">the address of the document</span>
@@ -577,13 +586,13 @@
   kind of <code><a href="#storage-0">Storage</a></code> area as was affected (i.e. session or
   local).<h4 id="event-definition"><span class="secno">4.4.1 </span>Event definition</h4><pre class="idl">interface <dfn id="storageevent">StorageEvent</dfn> : Event {
   readonly attribute DOMString <a href="#dom-storageevent-key" title="dom-StorageEvent-key">key</a>;
-  readonly attribute DOMString <a href="#dom-storageevent-oldvalue" title="dom-StorageEvent-oldValue">oldValue</a>;
-  readonly attribute DOMString <a href="#dom-storageevent-newvalue" title="dom-StorageEvent-newValue">newValue</a>;
+  readonly attribute any <a href="#dom-storageevent-oldvalue" title="dom-StorageEvent-oldValue">oldValue</a>;
+  readonly attribute any <a href="#dom-storageevent-newvalue" title="dom-StorageEvent-newValue">newValue</a>;
   readonly attribute DOMString <a href="#dom-storageevent-url" title="dom-StorageEvent-url">url</a>;
   readonly attribute <span>WindowProxy</span> <a href="#dom-storageevent-source" title="dom-StorageEvent-source">source</a>;
   readonly attribute <a href="#storage-0">Storage</a> <a href="#dom-storageevent-storagearea" title="dom-StorageEvent-storageArea">storageArea</a>;
-  void <a href="#dom-storageevent-initstorageevent" title="dom-StorageEvent-initStorageEvent">initStorageEvent</a>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in DOMString oldValueArg, in DOMString newValueArg, in DOMString urlArg, in <span>WindowProxy</span> sourceArg, in <a href="#storage-0">Storage</a> storageAreaArg);
-  void <a href="#dom-storageevent-initstorageeventns" title="dom-StorageEvent-initStorageEventNS">initStorageEventNS</a>(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in DOMString oldValueArg, in DOMString newValueArg, in DOMString urlArg, in <span>WindowProxy</span> sourceArg, in <a href="#storage-0">Storage</a> storageAreaArg);
+  void <a href="#dom-storageevent-initstorageevent" title="dom-StorageEvent-initStorageEvent">initStorageEvent</a>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in any oldValueArg, in any newValueArg, in DOMString urlArg, in <span>WindowProxy</span> sourceArg, in <a href="#storage-0">Storage</a> storageAreaArg);
+  void <a href="#dom-storageevent-initstorageeventns" title="dom-StorageEvent-initStorageEventNS">initStorageEventNS</a>(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in any oldValueArg, in any newValueArg, in DOMString urlArg, in <span>WindowProxy</span> sourceArg, in <a href="#storage-0">Storage</a> storageAreaArg);
 };</pre><p>The <dfn id="dom-storageevent-initstorageevent" title="dom-StorageEvent-initStorageEvent"><code>initStorageEvent()</code></dfn>
   and <dfn id="dom-storageevent-initstorageeventns" title="dom-StorageEvent-initStorageEventNS"><code>initStorageEventNS()</code></dfn>
   methods must initialize the event in a manner analogous to the

Received on Thursday, 6 August 2009 23:44:38 UTC