- From: poot <cvsmail@w3.org>
- Date: Tue, 22 Sep 2009 07:33:22 +0900 (JST)
- To: public-html-diffs@w3.org
hixie: Add replaceState() to let people update the state without adding billions of entries to the session history (whatwg r3933) http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.3094&r2=1.3095&f=h http://html5.org/tools/web-apps-tracker?from=3932&to=3933 =================================================================== RCS file: /sources/public/html5/spec/Overview.html,v retrieving revision 1.3094 retrieving revision 1.3095 diff -u -d -r1.3094 -r1.3095 --- Overview.html 21 Sep 2009 11:09:16 -0000 1.3094 +++ Overview.html 21 Sep 2009 22:32:50 -0000 1.3095 @@ -48289,6 +48289,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><dl class="domintro"><dt><var title="">window</var> . <code title="dom-history"><a href="#dom-history">history</a></code> . <code title="dom-history-length"><a href="#dom-history-length">length</a></code></dt> @@ -48338,6 +48339,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> @@ -48419,7 +48428,11 @@ </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 @@ -48433,13 +48446,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 @@ -48447,21 +48460,39 @@ </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> @@ -48475,9 +48506,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> @@ -48549,7 +48577,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>
Received on Monday, 21 September 2009 22:33:58 UTC