HTML5 Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/3933

SVNBugCommentTime (UTC)
39337419Add replaceState() to let people update the state without adding billions of entries to the session history2009-09-21 22:39
Index: source
===================================================================
--- source	(revision 3932)
+++ source	(revision 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">&lt;path&gt;</span>, <span
      title="url-query">&lt;query&gt;</span>, and <span
      title="url-fragment">&lt;fragment&gt;</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>
 

|