[html5] r3933 - [] (0) Add replaceState() to let people update the state without adding billions [...]

whatwg at whatwg.org whatwg at whatwg.org
Mon Sep 21 15:39:40 PDT 2009


Author: ianh
Date: 2009-09-21 15:39:39 -0700 (Mon, 21 Sep 2009)
New Revision: 3933

Modified:
   index
   source
Log:
[] (0) Add replaceState() to let people update the state without adding billions of entries to the session history
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=7419

Modified: index
===================================================================
--- index	2009-09-21 11:16:00 UTC (rev 3932)
+++ index	2009-09-21 22:39:39 UTC (rev 3933)
@@ -53546,6 +53546,7 @@
   void <a href=#dom-history-back title=dom-history-back>back</a>();
   void <a href=#dom-history-forward title=dom-history-forward>forward</a>();
   void <a href=#dom-history-pushstate title=dom-history-pushState>pushState</a>(in any data, in DOMString title, optional in DOMString url);
+  void <a href=#dom-history-replacestate title=dom-history-replaceState>replaceState</a>(in any data, in DOMString title, optional in DOMString url);
   void <a href=#dom-history-clearstate title=dom-history-clearState>clearState</a>();
 };</pre>
 
@@ -53597,6 +53598,14 @@
 
    </dd>
 
+   <dt><var title="">window</var> . <code title=dom-history><a href=#dom-history>history</a></code> . <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState</a></code>(<var title="">data</var>, <var title="">title</var> [, <var title="">url</var> ] )</dt>
+
+   <dd>
+
+    <p>Updates the current entry in the session histor to have the given data, title, and, if provided, URL.</p>
+
+   </dd>
+
    <dt><var title="">window</var> . <code title=dom-history><a href=#dom-history>history</a></code> . <code title=dom-history-clearState><a href=#dom-history-clearstate>clearState</a></code>()</dt>
 
    <dd>
@@ -53684,8 +53693,12 @@
    </table><hr><p>The <dfn id=dom-history-pushstate title=dom-history-pushState><code>pushState(<var title="">data</var>, <var title="">title</var>, <var title="">url</var>)</code></dfn> method adds a state object to the
   history.</p>
 
-  <p>When this method is invoked, the user agent must run the following steps:</p>
+  <p>The <dfn id=dom-history-replacestate title=dom-history-replaceState><code>replaceState(<var title="">data</var>, <var title="">title</var>, <var title="">url</var>)</code></dfn> method updates the <a href=#current-entry>current
+  entry</a> in the history to have a state object.</p>
 
+  <p>When either of these methods are invoked, the user agent must run
+  the following steps:</p>
+
   <ol><li><p>Let <var title="">clone data</var> be a <a href=#structured-clone>structured
    clone</a> of the specified <var title="">data</var>. If this
    throws an exception, then rethrow that exception and abort these
@@ -53698,13 +53711,13 @@
     <ol><li><a href=#resolve-a-url title="resolve a url">Resolve</a> the value of the
      third argument, relative to the <a href=#first-script>first script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>.</li>
 
-     <li>If that fails, raise a <code><a href=#security_err>SECURITY_ERR</a></code> exception and
-     abort the <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code>
-     steps.</li>
+     <li>If that fails, raise a <code><a href=#security_err>SECURITY_ERR</a></code> exception
+     and abort these steps.</li>
 
      <li>Compare the resulting <a href=#absolute-url>absolute URL</a> to <a href="#the-document's-address">the
      document's address</a>. If any part of these two <a href=#url title=URL>URLs</a> differ other than the <a href=#url-path title=url-path><path></a>, <a href=#url-query title=url-query><query></a>, and <a href=#url-fragment title=url-fragment><fragment></a> components, then
-     raise a <code><a href=#security_err>SECURITY_ERR</a></code> exception and abort the <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code> steps.</li>
+     raise a <code><a href=#security_err>SECURITY_ERR</a></code> exception and abort these
+     steps.</li>
 
     </ol><p>For the purposes of the comparison in the above substeps, the
     <a href=#url-path title=url-path><path></a> and <a href=#url-query title=url-query><query></a> components can only be the
@@ -53712,22 +53725,40 @@
 
    </li>
 
-   <li><p>Remove from the <a href=#session-history>session history</a> any entries for
-   the <code>Document</code> from the entry after the <a href=#current-entry>current
-   entry</a> up to the last entry in the session history that
-   references the same <code>Document</code> object, if any. If the
-   <a href=#current-entry>current entry</a> is the last entry in the session
-   history, or if there are no entries after the <a href=#current-entry>current
-   entry</a> that reference the same <code>Document</code> object,
-   then no entries are removed.</li>
+   <li>
 
-   <li><p>Add a state object entry to the session history, after the
-   <a href=#current-entry>current entry</a>, with <var title="">cloned data</var> as
-   the state object, the given <var title="">title</var> as the title,
-   and, if the third argument is present, the <a href=#absolute-url>absolute
-   URL</a> that was found earlier in this algorithm as the
-   <a href=#url>URL</a> of the entry.</li>
+    <p>If the method invoked was the <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code> method:</p>
 
+    <ol><li><p>Remove from the <a href=#session-history>session history</a> any entries for
+     the <code>Document</code> from the entry after the <a href=#current-entry>current
+     entry</a> up to the last entry in the session history that
+     references the same <code>Document</code> object, if any. If the
+     <a href=#current-entry>current entry</a> is the last entry in the session
+     history, or if there are no entries after the <a href=#current-entry>current
+     entry</a> that reference the same <code>Document</code> object,
+     then no entries are removed.</li>
+
+     <li><p>Add a state object entry to the session history, after the
+     <a href=#current-entry>current entry</a>, with <var title="">cloned data</var> as
+     the state object, the given <var title="">title</var> as the title,
+     and, if the third argument is present, the <a href=#absolute-url>absolute
+     URL</a> that was found earlier in this algorithm as the
+     <a href=#url>URL</a> of the entry.</li>
+
+     <li><p>Update the <a href=#current-entry>current entry</a> to be the this newly
+     added entry.</li>
+
+    </ol><p>Otherwise, if the method invoked was the <code title=dom-history-replaceState><a href=#dom-history-replacestate>replaceState()</a></code> method:</p>
+
+    <ol><li><p>Update the <a href=#current-entry>current entry</a> in the session
+     history so that <var title="">cloned data</var> is the entry's
+     new state object, the given <var title="">title</var> is the new
+     title, and, if the third argument is present, the <a href=#absolute-url>absolute
+     URL</a> that was found earlier in this algorithm is the
+     entry's new <a href=#url>URL</a>.</li>
+
+    </ol></li>
+
    <li>
 
     <p>If the third argument is present, set <a href="#the-document's-current-address">the document's
@@ -53740,9 +53771,6 @@
 
    </li>
 
-   <li><p>Update the <a href=#current-entry>current entry</a> to be the this newly
-   added entry.</li>
-
   </ol><p class=note>The <var title="">title</var> is purely
   advisory. User agents might use the title in the user interface.</p>
 
@@ -53823,7 +53851,7 @@
 
    <dd>
 
-    <p>Returns the information that was provided to <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code>.</p>
+    <p>Returns the information that was provided to <code title=dom-history-pushState><a href=#dom-history-pushstate>pushState()</a></code> or <code title=dom-history-replaceState><a href=#dom-history-replacestate>replaceState()</a></code>.</p>
 
    </dd>
 

Modified: source
===================================================================
--- source	2009-09-21 11:16:00 UTC (rev 3932)
+++ source	2009-09-21 22:39:39 UTC (rev 3933)
@@ -60554,6 +60554,7 @@
   void <span title="dom-history-back">back</span>();
   void <span title="dom-history-forward">forward</span>();
   void <span title="dom-history-pushState">pushState</span>(in any data, in DOMString title, optional in DOMString url);
+  void <span title="dom-history-replaceState">replaceState</span>(in any data, in DOMString title, optional in DOMString url);
   void <span title="dom-history-clearState">clearState</span>();
 };</pre>
 
@@ -60607,6 +60608,14 @@
 
    </dd>
 
+   <dt><var title="">window</var> . <code title="dom-history">history</code> . <code title="dom-history-pushState">pushState</code>(<var title="">data</var>, <var title="">title</var> [, <var title="">url</var> ] )</dt>
+
+   <dd>
+
+    <p>Updates the current entry in the session histor to have the given data, title, and, if provided, URL.</p>
+
+   </dd>
+
    <dt><var title="">window</var> . <code title="dom-history">history</code> . <code title="dom-history-clearState">clearState</code>()</dt>
 
    <dd>
@@ -60720,8 +60729,14 @@
   title="">url</var>)</code></dfn> method adds a state object to the
   history.</p>
 
-  <p>When this method is invoked, the user agent must run the following steps:</p>
+  <p>The <dfn title="dom-history-replaceState"><code>replaceState(<var
+  title="">data</var>, <var title="">title</var>, <var
+  title="">url</var>)</code></dfn> method updates the <span>current
+  entry</span> in the history to have a state object.</p>
 
+  <p>When either of these methods are invoked, the user agent must run
+  the following steps:</p>
+
   <ol>
 
    <li><p>Let <var title="">clone data</var> be a <span>structured
@@ -60739,9 +60754,8 @@
      third argument, relative to the <span>first script</span>'s <span
      title="script's base URL">base URL</span>.</li>
 
-     <li>If that fails, raise a <code>SECURITY_ERR</code> exception and
-     abort the <code title="dom-history-pushState">pushState()</code>
-     steps.</li>
+     <li>If that fails, raise a <code>SECURITY_ERR</code> exception
+     and abort these steps.</li>
 
      <li>Compare the resulting <span>absolute URL</span> to <span>the
      document's address</span>. If any part of these two <span
@@ -60749,8 +60763,8 @@
      title="url-path"><path></span>, <span
      title="url-query"><query></span>, and <span
      title="url-fragment"><fragment></span> components, then
-     raise a <code>SECURITY_ERR</code> exception and abort the <code
-     title="dom-history-pushState">pushState()</code> steps.</li>
+     raise a <code>SECURITY_ERR</code> exception and abort these
+     steps.</li>
 
     </ol>
 
@@ -60762,22 +60776,50 @@
 
    </li>
 
-   <li><p>Remove from the <span>session history</span> any entries for
-   the <code>Document</code> from the entry after the <span>current
-   entry</span> up to the last entry in the session history that
-   references the same <code>Document</code> object, if any. If the
-   <span>current entry</span> is the last entry in the session
-   history, or if there are no entries after the <span>current
-   entry</span> that reference the same <code>Document</code> object,
-   then no entries are removed.</p></li>
+   <li>
 
-   <li><p>Add a state object entry to the session history, after the
-   <span>current entry</span>, with <var title="">cloned data</var> as
-   the state object, the given <var title="">title</var> as the title,
-   and, if the third argument is present, the <span>absolute
-   URL</span> that was found earlier in this algorithm as the
-   <span>URL</span> of the entry.</p></li>
+    <p>If the method invoked was the <code
+    title="dom-history-pushState">pushState()</code> method:</p>
 
+    <ol>
+
+     <li><p>Remove from the <span>session history</span> any entries for
+     the <code>Document</code> from the entry after the <span>current
+     entry</span> up to the last entry in the session history that
+     references the same <code>Document</code> object, if any. If the
+     <span>current entry</span> is the last entry in the session
+     history, or if there are no entries after the <span>current
+     entry</span> that reference the same <code>Document</code> object,
+     then no entries are removed.</p></li>
+
+     <li><p>Add a state object entry to the session history, after the
+     <span>current entry</span>, with <var title="">cloned data</var> as
+     the state object, the given <var title="">title</var> as the title,
+     and, if the third argument is present, the <span>absolute
+     URL</span> that was found earlier in this algorithm as the
+     <span>URL</span> of the entry.</p></li>
+
+     <li><p>Update the <span>current entry</span> to be the this newly
+     added entry.</p></li>
+
+    </ol>
+
+    <p>Otherwise, if the method invoked was the <code
+    title="dom-history-replaceState">replaceState()</code> method:</p>
+
+    <ol>
+
+     <li><p>Update the <span>current entry</span> in the session
+     history so that <var title="">cloned data</var> is the entry's
+     new state object, the given <var title="">title</var> is the new
+     title, and, if the third argument is present, the <span>absolute
+     URL</span> that was found earlier in this algorithm is the
+     entry's new <span>URL</span>.</p></li>
+
+    </ol>
+
+   </li>
+
    <li>
 
     <p>If the third argument is present, set <span>the document's
@@ -60792,9 +60834,6 @@
 
    </li>
 
-   <li><p>Update the <span>current entry</span> to be the this newly
-   added entry.</p></li>
-
   </ol>
 
   <p class="note">The <var title="">title</var> is purely
@@ -60894,7 +60933,9 @@
 
    <dd>
 
-    <p>Returns the information that was provided to <code title="dom-history-pushState">pushState()</code>.</p>
+    <p>Returns the information that was provided to <code
+    title="dom-history-pushState">pushState()</code> or <code
+    title="dom-history-replaceState">replaceState()</code>.</p>
 
    </dd>
 




More information about the Commit-Watchers mailing list