undomanager.html
changeset 7 44f10659a665
parent 6 ac6ab5cf2890
child 8 17a725399127
--- a/undomanager.html	Tue May 29 22:54:02 2012 -0700
+++ b/undomanager.html	Tue May 29 23:19:44 2012 -0700
@@ -152,7 +152,8 @@
     
     <p>When the <code><a href=#attr-undoscope>undoscope</a></code> content attribute is removed from an <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editing-host>editing host</a>
     or an element that is not <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a>, the user agent must remove all entries in the <a href=#undo-transaction-history>undo transaction history</a>
-    of the corresponding <a href=#undo-scope>undo scope</a> without <a href=#dom-transaction-unapply>unapplying</a> or <a href=#dom-transaction-reapply>reapplying</a> them and destroy the corresponding <code><a href=#undomanager>UndoManager</a></code> for the scope.
+    of the corresponding <a href=#undo-scope>undo scope</a> without <a href=#dom-transaction-unapply>unapplying</a> or <a href=#dom-transaction-reapply>reapplying</a> them and
+    <a href=#disconnect-undomanager>disconnect</a> the corresponding <code><a href=#undomanager>UndoManager</a></code> for the scope.
     After the removal, the node from which the content attribute is removed and their descendent nodes, excluding <a href=#undo-scope-host>undo scope hosts</a> and their descendents,
     belong to the <a href=#undo-scope>undo scope</a> of the closest ancestor with
     the <code><a href=#attr-undoscope>undoscope</a></code> content attribute or of the document.</p>
@@ -165,7 +166,8 @@
     <p>When the <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable>contenteditable</a></code> content attribute is added to an element,
     the user agent must remove all entries in the <a href=#undo-transaction-history>undo transaction histories</a> of the editable <a href=#undo-scope>undo scope hosts</a> that are descendent of the element
     and have become <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a> without <a href=#dom-transaction-unapply>unapplying</a> or <a href=#dom-transaction-reapply>reapplying</a> the entries
-    and destroy the corresponding <code><a href=#undomanager>UndoManager</a></code>s as if the <code><a href=#attr-undoscope>undoscope</a></code> content attribute was removed from all descendent nodes
+    and <a href=#disconnect-undomanager>disconnect</a> the corresponding <code><a href=#undomanager>UndoManager</a></code>s
+    as if the <code><a href=#attr-undoscope>undoscope</a></code> content attribute was removed from all descendent nodes
     excluding <a href=#undo-scope-host>undo scope hosts</a> and their descendents.</p>
 
     <p>Conversely, when the <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable>contenteditable</a></code> content attribute is removed from an element,
@@ -262,8 +264,9 @@
 
         <p>The <dfn id=dom-undomanager-transact title=dom-UndoManager-transact><code>transact(<var title="">transaction</var>, <var title="">merge</var>)</code></dfn> will</p>
         <ol>
-            <li>If this <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> a <a href=#dom-transaction>DOM transaction</a>, then throw
+            <li>If this <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> a <a href=#dom-transaction>DOM transaction</a>,
+                or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, then 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.</li>
             <li>Clear all entries between before the current <a href=#undo-position>undo position</a> without <a href=#dom-transaction-unapply>unapplying</a>
             or <a href=#dom-transaction-reapply>reapplying</a> the <a href=#dom-transaction>transactions</a> in the entires.</li>
@@ -271,30 +274,33 @@
             <li>If <var title="">merge</var> is set to true, add an empty entry to the beginning of the <a href=#undo-transaction-history>undo transaction history</a>.</li>
             <li>Add the applied transaction to the beginning of the first entry in the <a href=#undo-transaction-history>undo transaction history</a>.</li>
             <li><a href=#fire-a-dom-transaction-event>Fire a DOM transaction event</a> for the transaction applied in step 3 at the <a href=#undo-scope-host>undo scope host</a>
-            of this <code><a href=#undomanager>UndoManager</a></code> if <a href=#undo-scope-host>undo scope host</a> is still in the document and <code><a href=#undomanager>UndoManager</a></code>
-            had not already been destroyed.</li>
+            of this <code><a href=#undomanager>UndoManager</a></code> if the <code><a href=#undomanager>UndoManager</a></code> had not already been <a href=#disconnect-undomanager>disconnected</a>.</li>
         </ol>
 
         <p>The <dfn id=dom-undomanager-undo title=dom-UndoManager-undo><code>undo()</code></dfn> will</p>
         <ol>
-            <li>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 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.</li>
+            <li>If this <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> a <a href=#dom-transaction>DOM transaction</a>,
+                or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, then 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.</li>
             <li>If <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> &le; <code title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></code>, stop.</li>
             <li>Otherwise, <a href=#dom-transaction-unapply>unapply</a> <a href=#dom-transaction>DOM transactions</a> in the entry immediately after
             the <a href=#undo-position>undo position</a> in the order and increment <a href=#dom-undomanager-position>position</a> by 1.</li>
-            <li><a href=#fire-an-undo-event>Fire an undo event</a> for the transaction unapplied in step 3 at the <a href=#undo-scope-host>undo scope host</a> of this <code><a href=#undomanager>UndoManager</a></code>
-            if <a href=#undo-scope-host>undo scope host</a> is still in the document and <code><a href=#undomanager>UndoManager</a></code> had not already been destroyed.</li>
+            <li><a href=#fire-an-undo-event>Fire an undo event</a> for the transaction unapplied in step 3 at the <a href=#undo-scope-host>undo scope host</a>
+            of this <code><a href=#undomanager>UndoManager</a></code> if the <code><a href=#undomanager>UndoManager</a></code> had not already been <a href=#disconnect-undomanager>disconnected</a>.</li>
         </ol>
 
         <p>The <dfn id=dom-undomanager-redo title=dom-UndoManager-redo><code>redo()</code></dfn> will</p>
         <ol>
-            <li>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 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.</li>
+            <li>If this <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> a <a href=#dom-transaction>DOM transaction</a>,
+                or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, then 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.</li>
             <li>If <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> &le; 0, stop.</li>
             <li>Otherwise, <a href=#dom-transaction-reapply>reapply</a> <a href=#dom-transaction>DOM transactions</a> in the entry immediately before
             the <a href=#undo-position>undo position</a> in the reverse order and decrement <a href=#dom-undomanager-position>position</a> by 1.</li>
-            <li><a href=#fire-a-redo-event>Fire a redo event</a> for the transaction unapplied in step 3 at the <a href=#undo-scope-host>undo scope host</a> of this <code><a href=#undomanager>UndoManager</a></code>
-            if <a href=#undo-scope-host>undo scope host</a> is still in the document and <code><a href=#undomanager>UndoManager</a></code> had not already been destroyed.</li>
+            <li><a href=#fire-a-redo-event>Fire a redo event</a> for the transaction unapplied in step 3 at the <a href=#undo-scope-host>undo scope host</a>
+            of this <code><a href=#undomanager>UndoManager</a></code> if the <code><a href=#undomanager>UndoManager</a></code> had not already been <a href=#disconnect-undomanager>disconnected</a>.</li>
         </ol>
 
         <p>The <dfn id=dom-undomanager-item title=dom-UndoManager-item><code>item(<var title="">n</var>)</code></dfn>
@@ -315,14 +321,29 @@
         This is the <var title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></var>.</p>
 
         <p>The <dfn id=dom-undomanager-clearundo title=dom-UndoManager-clearUndo><code>clearUndo()</code></dfn>
-        method must remove all entries in the <a href=#undo-transaction-history>undo transaction history</a> before the <a href=#undo-position>undo position</a>,
+        method 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>
+        if this <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> a <a href=#dom-transaction>DOM transaction</a>,
+        or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, 
+        otherwise it must remove all entries in the <a href=#undo-transaction-history>undo transaction history</a> before the <a href=#undo-position>undo position</a>,
         and move the <a href=#undo-position>undo position</a> to the top (set <a href=#dom-undomanager-position>position</a> to zero).</p>
 
         <p>The <dfn id=dom-undomanager-clearredo title=dom-UndoManager-clearRedo><code>clearRedo()</code></dfn>
-        method must remove all entries in the <a href=#undo-transaction-history>undo transaction history</a> after the <a href=#undo-position>undo position</a>.</p>
+        method 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>
+        if this <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> a <a href=#dom-transaction>DOM transaction</a>,
+        or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, 
+        otherwise it must remove all entries in the <a href=#undo-transaction-history>undo transaction history</a> after the <a href=#undo-position>undo position</a>.</p>
 
         <p><dfn id=the-active-undo-manager>The active undo manager</dfn> is the <code><a href=#undomanager>UndoManager</a></code> of the focused node in the document.
         If no node has focus, then it's assumed to be of the document.</p>
+
+        <p>To <dfn id=disconnect-undomanager>disconnect an UndoManager</dfn> means to deprive the ability to add or remove entries in
+        the <a href=#undo-transaction-history>undo transaction history</a> of the <code><a href=#undomanager>UndoManager</a></code>.
+        Once the <code><a href=#undomanager>UndoManager</a></code> is disconnected, <code><a href=#dom-undomanager-transact>transact</a>()</code>,
+        <code><a href=#dom-undomanager-undo>undo</a>()</code>, <code><a href=#dom-undomanager-redo>redo</a>()</code>, <code><a href=#dom-undomanager-clearundo>clearUndo</a>()</code>,
+        and <code><a href=#dom-undomanager-clearundo>clearRedo</a>()</code> will all 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>.<p>
     </div>
 
     <p>Each entry in the <a href=#undo-manager>UndoManager</a> consists of one or more <a href=#dom-transaction>DOM transactions</a>,
@@ -650,7 +671,7 @@
     <div class=example>
         <p>All <a href=#dom-changes>DOM changes</a> made in <code><a href=#dom-domtransaction-execute>execute</a></code> or
         <code><a id=dom-domtransaction-executeautomatic>executeAutomatic</a></code> take effect immediately.
-        Sometimes, this destroys the undoManager to which it belongs.</p>
+        Sometimes, this <a href=#disconnect-undomanager>disconnects</a> the undoManager to which it belongs.</p>
 
         <pre>var scope = document.createElement('div');
 scope.undoScope = true;