Permalink
Browse files

Updated the spec per Aryeh's initial feedback on http://lists.whatwg.…

  • Loading branch information...
1 parent 6a68bad commit b118ba4df066346613aaf0f0bbffb652f9abaac0 @rniwa committed Oct 27, 2011
Showing with 45 additions and 22 deletions.
  1. +22 −10 source.html
  2. +23 −12 undomanager.html
View
@@ -240,27 +240,27 @@ <h3 id="the-undomanager-interface">The <code><a href="#undomanager">UndoManager<
</ol>
<p>The <dfn id="dom-undomanager-undo" title="dom-UndoManager-undo"><code>undo()</code></dfn>
- <a href="#dom-transaction-unapply">unapplies</a> the <a href="#dom-transaction">DOM transaction</a> immediately after the <a href="#undo-position">undo position</a> and
+ <a href="#dom-transaction-unapply">unapplies</a> the <a href="#dom-transaction">DOM transaction</a> or the <a href="#dom-transaction-group">DOM transaction group</a> immediately after the <a href="#undo-position">undo position</a> and
moves the <a href="#undo-position">undo position</a> forward (<a href="#dom-undomanager-position">position</a></code> is incremented by 1) if
<code title="dom-UndoManager-position"><a href="#dom-undomanager-position">position</a></code> &lt;
<code title="dom-UndoManager-length"><a href="#dom-undomanager-length">length</a></code> and <code><a href="#undomanager">UndoManager</a></code> is not already in the process of
- <a href="#dom-transaction-apply">applying</a>, <a href="#dom-transaction-unapply">unapplying</a>, or <a href="dom-transaction-reapply">reapplying</a> a <a href="#dom-transaction">DOM transaction</a>.
+ <a href="#dom-transaction-apply">applying</a>, <a href="#dom-transaction-unapply">unapplying</a>, or <a href="dom-transaction-reapply">reapplying</a> a <a href="#dom-transaction">DOM transaction</a> or a <a href="#dom-transaction-group">DOM transaction group</a>.
If <code><a href="#undomanager">UndoManager</a></code> is already in the process of <a href="#dom-transaction-apply">applying</a>, <a href="#dom-transaction-unapply">unapplying</a>,
or <a href="dom-transaction-reapply">reapplying</a>, then it must throw <code class="external"><a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMException-INVALID_ACCESS_ERR">INVALID_ACCESS_ERR</a></code>
and stop. Otherwise, it must do nothing.</p>
<p>The <dfn id="dom-undomanager-redo" title="dom-UndoManager-redo"><code>redo()</code></dfn>
- <a href="#dom-transaction-reapply">reapplies</a> the <a href="#dom-transaction">DOM transaction</a> immediately before the <a href="#undo-position">undo position</a> and
+ <a href="#dom-transaction-reapply">reapplies</a> the <a href="#dom-transaction">DOM transaction</a> or the <a href="#dom-transaction-group">DOM transaction group</a> immediately before the <a href="#undo-position">undo position</a> and
moves the <a href="#undo-position">undo position</a> backward (<a href="#dom-undomanager-position">position</a></code> is incremented by 1) if
<code title="dom-UndoManager-position"><a href="#dom-undomanager-position">position</a></code> &gt; 0 and <code><a href="#undomanager">UndoManager</a></code> is not already in the process of
- <a href="#dom-transaction-apply">applying</a>, <a href="#dom-transaction-unapply">unapplying</a>, or <a href="dom-transaction-reapply">reapplying</a> a <a href="#dom-transaction">DOM transaction</a>.
+ <a href="#dom-transaction-apply">applying</a>, <a href="#dom-transaction-unapply">unapplying</a>, or <a href="dom-transaction-reapply">reapplying</a> a <a href="#dom-transaction">DOM transaction</a> or a <a href="#dom-transaction-group">DOM transaction group</a>.m
If <code><a href="#undomanager">UndoManager</a></code> is already in the process of <a href="#dom-transaction-apply">applying</a>, <a href="#dom-transaction-unapply">unapplying</a>,
or <a href="dom-transaction-reapply">reapplying</a>, then it must throw <code class="external"><a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMException-INVALID_ACCESS_ERR">INVALID_ACCESS_ERR</a></code>
and stop. Otherwise, it must do nothing.</p>
<p>The <dfn id="dom-undomanager-item" title="dom-UndoManager-item"><code>item(<var title="">n</var>)</code></dfn>
- method must return the <var title="">n</var>th <a href="#dom-transaction">DOM transaction</a>'s <a href="#transaction-associated-data">associated data</a> in
- the <a href="#undo-transaction-history">undo transaction history</a>, if there is one, or null otherwise.</p>
+ method must return the <var title="">n</var>th entry, a <a href="#dom-transaction">DOM transaction</a> or an array reprensenting a <a href="#dom-transaction-group">DOM transaction group</a>,
+ in the <a href="#undo-transaction-history">undo transaction history</a> if there is one, or null otherwise.</p>
<p class="note">Being able to access an arbitrary element in the <a href="#undo-transaction-history">undo transaction history</a> is needed to allow scripts to determine
whether new DOM transaction and the last DOM transaction should form a <a href="#dom-transaction-group">DOM transaction group</a>.</p>
@@ -346,7 +346,7 @@ <h4 id="undoManager-idl-attribute">undoManager IDL attribute</h4>
If the node is not an <a href="#undo-scope-host">undo scope host</a>, it must return <code>null</code>.</p>
</div>
-<h3 id="undo-moving-back-in-the-undo-transaction-history">Undo: moving back in the undo transaction history</h3>
+<h3 id="undo-moving-back-in-the-undo-transaction-history">Undo: moving forward in the undo transaction history</h3>
<p>When the user invokes an undo operation, or when the
<code class="external"><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#execCommand">execCommand()</a></code> method is called with
@@ -359,7 +359,7 @@ <h3 id="undo-moving-back-in-the-undo-transaction-history">Undo: moving back in t
<p>Otherwise, the user agent must <a href="#dom-transaction-unapply">unapply</a> the <a href="#dom-transaction">DOM transaction</a> immediately after the <a href="#undo-position">undo position</a>
and move the <a href="#undo-position">undo position</a> forward (increment <a href="#dom-undomanager-position">position</a></code> by 1).</p>
-<h3 id="redo-moving-forward-in-the-redo-transaction-history">Redo: moving forward in the undo transaction history</h3>
+<h3 id="redo-moving-forward-in-the-redo-transaction-history">Redo: moving backward in the undo transaction history</h3>
<p>When the user invokes a redo operation, or when the
<code class="external"><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#execCommand">execCommand()</a></code> method is called with
@@ -379,7 +379,7 @@ <h2 id="transaction-and-dom-changes">Transaction and DOM changes</h2>
<p>To <dfn id="dom-transaction-apply" title="dom-transaction-apply">apply</dfn> a <a href="#dom-transaction">DOM transaction</a> means to make the associated <a href="#dom-changes">DOM changes</a>
under the associated <a href="#undo-scope-host">undo scope host</a>.
- And to <dfn id="dom-transaction-unapply" title="dom-transaction-unapply">unapply</dfn> and to <dfn id="dom-transaction-reapply" title="dom-transaction-unapply">reapply</dfn>
+ And to <dfn id="dom-transaction-unapply" title="dom-transaction-unapply">unapply</dfn> and to <dfn id="dom-transaction-reapply" title="dom-transaction-reapply">reapply</dfn>
a <a href="#dom-transaction">DOM transaction</a> means, respectively, to revert and to remake the associated <a href="#dom-changes">DOM changes</a> under the associated <a href="#undo-scope-host">undo scope host</a>.
<p>A <a href="#dom-transaction">DOM transaction</a> can be <a href="#dom-transaction-unapply">unapplied</a> or <a href="#dom-transaction-reapply">reapplied</a> if it appears, respectively, immediately after or immediately before
@@ -397,7 +397,7 @@ <h3 id="mutations-of-dom">Mutations of DOM</h3>
<p>The <dfn>DOM state</dfn> of an element is the state of all descendent elements and their attributes that are transient
under <a href="#dom-changes">DOM changes</a> of the element.</p>
- <p>To <dfn>restore DOM state</dfn> of a node means to undo <dfn>DOM changes</dfn> made to the node by means of inserting, removing, or moving descendent nodes
+ <p>To <dfn>restore DOM state</dfn> of a node means to undo <a href="#dom-changes">DOM changes</a> made to the node by means of inserting, removing, or moving descendent nodes
or attributes of the node.</p>
<h3 id="the-transaction-interface">The <code><a href="#dom-domtransaction">DOMTransaction</a></code> interface</h3>
@@ -421,6 +421,18 @@ <h3 id="the-transaction-interface">The <code><a href="#dom-domtransaction">DOMTr
<dfn id="dom-domtransaction-reapply"><code>reapply</code></dfn> are attributes that must be supported, as IDL attributes, by objects implementing
the <code><a href="#dom-transaction">Transaction</a></code> interface.</p>
+ <p class="note">Any changes made to the value of <code><a href="#dom-domtransaction-apply">apply</a></code>, <code><a href="#dom-domtransaction-unapply">unapply</a></code>,
+ or <code><a href="#dom-domtransaction-reapply">reapply</a></code> attributes will take effect immediately. In the following example, <code><a href="#dom-domtransaction-apply">apply</a></code>
+ and <code><a href="#dom-domtransaction-unapply">unapply</a></code> attributes are modified:</p>
+ <pre class="example">
+document.undoManager.transact({ apply: function () {
+ this.apply = function () { alert('foo'); }
+ alert('bar');
+}, unapply: function () { alert('baz'); } }); // alerts 'bar'
+document.undoManager.item(0).unapply = function() { alert('foobar'); }
+docuemnt.undoManager.undo(); // alerts 'foobar'
+</pre>
+
<p><dfn id="dom-domtransaction-isAutomatic"><code>isAutomatic</code></dfn> attribute must return <code>true</code> if the transaction is a <a href="#automatic-dom-transaction">automatic DOM transaction</a>,
and <code>false</code> if it is a <a href="#manual-dom-transaction">manual DOM transaction</a> immediately before the transaction is <a href="#dom-transaction-apply">applied</a>.
Any changes made to the value of the <code><a href="#dom-domtransaction-isAutomatic">isAutomatic</a></code> attribute while the transaction is being <a href="#dom-transaction-apply">applied</a> or after the transaction had been <a href="#dom-transaction-apply">applied</a>
Oops, something went wrong.

0 comments on commit b118ba4

Please sign in to comment.