--- a/editcommands.html Tue May 17 14:03:31 2011 -0600
+++ b/editcommands.html Tue May 17 14:47:39 2011 -0600
@@ -370,38 +370,64 @@
<ol>
<li>If <var title="">node list</var> is empty, or the first member of <var title="">node
- list</var> is not <a href=#editable>editable</a>, abort these steps.
+ list</var> is not <a href=#editable>editable</a>, return null and abort these steps.
+
+ <li>Let <var title="">original parent</var> be the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first member of
+ <var title="">node list</var>.
<li>If the <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code> of the first member of <var title="">node list</var>
- is <a href=#editable>editable</a> and meets the <a href=#sibling-criteria>sibling criteria</a>, then
- for each <var title="">node</var> in <var title="">node list</var>, append <var title="">node</var> as
- the last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of its <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code>, <a href=#preserving-ranges>preserving
- ranges</a>. Then abort these steps.
+ is <a href=#editable>editable</a> and meets the <a href=#sibling-criteria>sibling criteria</a>:
+
+ <ol>
+ <li>For each <var title="">node</var> in <var title="">node list</var>, append
+ <var title="">node</var> as the last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of its <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code>,
+ <a href=#preserving-ranges>preserving ranges</a>.
+
+ <li>If <var title="">original parent</var> is <a href=#editable>editable</a> and has no
+ <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>children</a>, remove it from its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>.
+
+ <li>Return the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first member of <var title="">node list</var> and
+ abort these steps.
+ </ol>
<li>If the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last member of <var title="">node list</var> is
- <a href=#editable>editable</a> and meets the <a href=#sibling-criteria>sibling criteria</a>, then for
- each <var title="">node</var> in <var title="">node list</var>, <em>in reverse order</em>,
- insert <var title="">node</var> as the first <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of its <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code>,
- <a href=#preserving-ranges>preserving ranges</a>. Then abort these steps.
+ <a href=#editable>editable</a> and meets the <a href=#sibling-criteria>sibling criteria</a>:
+
+ <ol>
+ <li>For each <var title="">node</var> in <var title="">node list</var>, <em>in reverse
+ order</em>, insert <var title="">node</var> as the first <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of its
+ <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code>, <a href=#preserving-ranges>preserving ranges</a>.
+
+ <li>If <var title="">original parent</var> is <a href=#editable>editable</a> and has no
+ <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>children</a>, remove it from its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>.
+
+ <li>Return the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first member of <var title="">node list</var> and
+ abort these steps.
+ </ol>
<li>Run the <a href=#new-parent-instructions>new parent instructions</a>, and let <var title="">new
parent</var> be the result.
- <li>If <var title="">new parent</var> cannot be the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the
- first member of <var title="">node list</var>, <a href=#split-the-parent>split the parent</a> of
- <var title="">node list</var>.
+ <li>If <var title="">new parent</var>'s <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> is null, and <var title="">new parent</var>
+ cannot be the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first member of <var title="">node
+ list</var>, <a href=#split-the-parent>split the parent</a> of <var title="">node list</var>.
<p class=XXX>"Cannot be the child" needs to be defined.
- <li>Insert <var title="">new parent</var> into the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first member of
- <var title="">node list</var> immediately before the first member of <var title="">node
- list</var>.
+ <li>If <var title="">new parent</var>'s <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> is null, insert <var title="">new
+ parent</var> into the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first member of <var title="">node list</var>
+ immediately before the first member of <var title="">node list</var>.
<li>For each <var title="">node</var> in <var title="">node list</var>, append <var title="">node</var>
as the last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of <var title="">new parent</var>, <a href=#preserving-ranges>preserving
ranges</a>.
+ <li>If <var title="">original parent</var> is <a href=#editable>editable</a> and has no
+ <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>children</a>, remove it from its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>.
+
<li><a href=#remove-extraneous-line-breaks>Remove extraneous line breaks</a> from <var title="">new parent</var>.
+
+ <li>Return <var title="">new parent</var>.
</ol>
<p>To <dfn id=remove-extraneous-line-breaks>remove extraneous line breaks</dfn> from a <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> <var title="">node</var>:
@@ -2766,20 +2792,21 @@
<li>While <var title="">node list</var> is not empty:
<ol>
- <li>Let <var title="">sublist</var> be an empty list of <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>nodes</a>.
-
- <li>Remove the first member of <var title="">node list</var> and append it to
- <var title="">sublist</var>.
-
- <li>If the first member of <var title="">sublist</var> is an <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>,
- <a href=#outdent>outdent</a> it.
-
- <li>Otherwise, if the first member of <var title="">sublist</var> is a <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>,
- <a href=#set-the-tag-name>set the tag name</a> of the first member of <var title="">sublist</var> to
- "ol".
-
- <li>Otherwise, if the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first member of <var title="">sublist</var>
- is an <a href=#editable>editable</a> <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>:
+ <li>Let <var title="">node</var> be the first member of <var title="">node list</var>.
+
+ <li>Remove <var title="">node</var> from <var title="">node list</var>.
+
+ <li>If <var title="">node</var> is an <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>, <a href=#outdent>outdent</a> it and continue
+ from the beginning of this loop.
+
+ <li>If <var title="">node</var> is a <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>, <a href=#set-the-tag-name>set the tag name</a> of
+ <var title="">node</var> to "ol" and continue from the beginning of this loop.
+
+ <li>Let <var title="">sublist</var> be a list of <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>nodes</a>, initially consisting of
+ <var title="">node</var>.
+
+ <li>If the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of <var title="">node</var> is an <a href=#editable>editable</a>
+ <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>:
<!-- Outdent -->
<ol>
@@ -2792,10 +2819,12 @@
<li><a href=#split-the-parent>Split the parent</a> of <var title="">sublist</var>.
<li><a href=#fix-orphaned-list-items>Fix orphaned list items</a> in <var title="">sublist</var>.
+
+ <li>Continue from the beginning of this loop.
</ol>
- <li>Otherwise, if the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first member of <var title="">sublist</var>
- is an <a href=#editable>editable</a> <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>:
+ <li>If the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of <var title="">node</var> is an <a href=#editable>editable</a>
+ <code class=external data-anolis-spec=html title="the ul element"><a href=http://www.whatwg.org/html/#the-ul-element>ul</a></code>:
<!-- Split up the parent -->
<ol>
@@ -2811,114 +2840,62 @@
criteria</a> matching any <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>, and with <a href=#new-parent-instructions>new parent
instructions</a> returning the result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("ol")</a></code> on the
<a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.
+
+ <li>Continue from the beginning of this loop.
</ol>
- <li>Otherwise:
<!-- General case. Add an ol wrapper for each line. <br> breaks apart
<li>'s, and multiple consecutive <br>s or trailing <br>s become empty
<li>s. -->
+ <li>If <var title="">node</var> is a <code class=external data-anolis-spec=html title="the p element"><a href=http://www.whatwg.org/html/#the-p-element>p</a></code> or <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/html/#the-li-element>li</a></code> or <code class=external data-anolis-spec=html title="the div element"><a href=http://www.whatwg.org/html/#the-div-element>div</a></code>, <a href=#set-the-tag-name>set the tag
+ name</a> of <var title="">node</var> to "li", and let <var title="">li</var> be the
+ result.
+
+ <li>Otherwise:
+
<ol>
- <li>If the first member of <var title="">sublist</var> is a <code class=external data-anolis-spec=html title="the p element"><a href=http://www.whatwg.org/html/#the-p-element>p</a></code> or <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/html/#the-li-element>li</a></code> or
- <code class=external data-anolis-spec=html title="the div element"><a href=http://www.whatwg.org/html/#the-div-element>div</a></code>, <a href=#set-the-tag-name>set the tag name</a> of the first member of
- <var title="">sublist</var> to "li", and let <var title="">li</var> be the result. Remove
- the first member of <var title="">sublist</var>, and append <var title="">li</var> to
+ <li>While <var title="">node list</var> is not empty, and the first member of
+ <var title="">node list</var> is the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last member of
+ <var title="">sublist</var>, and the last member of <var title="">sublist</var> and first
+ member of <var title="">node list</var> are both <a href=#inline-node title="inline node">inline
+ nodes</a>, and the last member of <var title="">sublist</var> is not a <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code>,
+ remove the first member from <var title="">node list</var> and append it to
<var title="">sublist</var>.
- <li>Otherwise:
-
- <ol>
- <li>While <var title="">node list</var> is not empty, and the first member of
- <var title="">node list</var> is the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last member of
- <var title="">sublist</var>, and the last member of <var title="">sublist</var> and first
- member of <var title="">node list</var> are both <a href=#inline-node title="inline
- node">inline nodes</a>, and the last member of <var title="">sublist</var> is
- not a <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/html/#the-br-element>br</a></code>, remove the first member from <var title="">node list</var> and
- append it to <var title="">sublist</var>.
-
- <li>Let <var title="">li</var> be the result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("li")</a></code> on the
- <code class=external data-anolis-spec=domcore title=dom-Node-ownerDocument><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>ownerDocument</a></code> of the first member of <var title="">sublist</var>.
- </ol>
-
- <li>If the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code> of the last member of <var title="">sublist</var> is an
- <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>:
-
- <ol>
- <li>Insert <var title="">li</var> as the first <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of the <code class=external data-anolis-spec=domcore title=dom-Node-nextSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-nextsibling>nextSibling</a></code>
- of the last member of <var title="">sublist</var>, <a href=#preserving-ranges>preserving
- ranges</a>.
-
- <li>If the first member of <var title="">sublist</var> is an <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/html/#the-li-element>li</a></code>, remove it
- from <var title="">sublist</var>.
-
- <li>For each <var title="">node</var> in <var title="">sublist</var> <em>in reverse
- order</em>, insert <var title="">node</var> as the first <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of
- <var title="">li</var>, <a href=#preserving-ranges>preserving ranges</a>.
- </ol>
-
- <li>Otherwise:
-
- <ol>
- <li>Let <var title="">ol</var> be the <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code> of the first member of
- <var title="">sublist</var>.
-
- <li>Let <var title="">original parent</var> be the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first
- member of <var title="">sublist</var>.
-
- <li>If <var title="">ol</var> is null, and <var title="">original parent</var> is an
- <a href=#editable>editable</a> <a href=#indentation-element>indentation element</a>, and the
- <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code> of <var title="">original parent</var> is an
- <a href=#editable>editable</a> <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>:
-
- <ol>
- <li>Let <var title="">ol</var> be the <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code> of <var title="">original
- parent</var>.
-
- <li><a href=#normalize-sublists>Normalize sublists</a> of <var title="">ol</var>'s last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a>.
-
- <li>If <var title="">ol</var>'s last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> is not an <a href=#editable>editable</a>
- <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>, call <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("ol")</a></code> on the
- <code class=external data-anolis-spec=domcore title=dom-Node-ownerDocument><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>ownerDocument</a></code> of <var title="">ol</var>, and append the result as the last
- <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of <var title="">ol</var>.
-
- <li>Set <var title="">ol</var> to its last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a>.
- </ol>
-
- <li>If <var title="">ol</var> is not an <a href=#editable>editable</a> <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>:
-
- <ol>
- <li>If <var title="">original parent</var> is a <code class=external data-anolis-spec=html title="the p element"><a href=http://www.whatwg.org/html/#the-p-element>p</a></code>, <a href=#split-the-parent>split the
- parent</a> of <var title="">sublist</var>, and then set <var title="">original
- parent</var> to the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of the first member of
- <var title="">sublist</var>.
-
- <li>Let <var title="">ol</var> be the result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("ol")</a></code> on the
- <code class=external data-anolis-spec=domcore title=dom-Node-ownerDocument><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-ownerdocument>ownerDocument</a></code> of the first member of <var title="">sublist</var>.
-
- <li>Insert <var title="">ol</var> into <var title="">original parent</var> immediately
- before the first member of <var title="">sublist</var>.
- </ol>
-
- <li>Append <var title="">li</var> as the last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of <var title="">ol</var>,
- <a href=#preserving-ranges>preserving ranges</a>.
-
- <li>If the first member of <var title="">sublist</var> is an <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/html/#the-li-element>li</a></code>, remove it
- from <var title="">sublist</var>.
-
- <li>For each <var title="">node</var> in <var title="">sublist</var>, append
- <var title="">node</var> as the last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of <var title="">li</var>,
- <a href=#preserving-ranges>preserving ranges</a>.
-
- <li>If <var title="">original parent</var> has no <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>children</a>, remove it from
- its <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>.
- <!-- This might happen if it's an indentation element whose previous
- sibling is an ol, for instance. -->
- </ol>
+ <li><a href=#wrap>Wrap</a> <var title="">sublist</var>, with <a href=#sibling-criteria>sibling
+ criteria</a> matching nothing and with <a href=#new-parent-instructions>new parent
+ instructions</a> returning the result of calling <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("li")</a></code> on the
+ <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>. Let <var title="">li</var> be the result.
</ol>
- <li><a href=#remove-extraneous-line-breaks>Remove extraneous line breaks</a> from <var title="">ol</var>.
-
- <li><a href=#remove-extraneous-line-breaks>Remove extraneous line breaks</a> from <var title="">li</var>.
+ <li>If <var title="">li</var> is null, continue from the beginning of this loop.
+
+ <li><a href=#wrap>Wrap</a> the one-<a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node title=concept-node>node</a> list consisting of <var title="">li</var>,
+ with the <a href=#sibling-criteria>sibling criteria</a> matching any <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>, and the
+ <a href=#new-parent-instructions>new parent instructions</a> being the following:
+
+ <ol>
+ <li>Let <var title="">original parent</var> be the <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of <var title="">li</var>.
+
+ <li>If <var title="">original parent</var> is not an <a href=#editable>editable</a>
+ <a href=#indentation-element>indentation element</a>, or the <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code> of
+ <var title="">original parent</var> is not an <a href=#editable>editable</a> <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>, call
+ <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("ol")</a></code> on the
+ <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a> and return the result. Otherwise:
+
+ <li>Let <var title="">ol</var> be the <code class=external data-anolis-spec=domcore title=dom-Node-previousSibling><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-previoussibling>previousSibling</a></code> of <var title="">original
+ parent</var>.
+
+ <li><a href=#normalize-sublists>Normalize sublists</a> of <var title="">ol</var>'s last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a>.
+
+ <li>If <var title="">ol</var>'s last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> is not an <a href=#editable>editable</a>
+ <code class=external data-anolis-spec=html title="the ol element"><a href=http://www.whatwg.org/html/#the-ol-element>ol</a></code>, call <code class=external data-anolis-spec=domcore title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("ol")</a></code> on the
+ <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>, and append the result as the last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of
+ <var title="">ol</var>.
+
+ <li>Return the last <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of <var title="">ol</var>.
+ </ol>
</ol>
</ol>
--- a/implementation.js Tue May 17 14:03:31 2011 -0600
+++ b/implementation.js Tue May 17 14:47:39 2011 -0600
@@ -328,12 +328,16 @@
// "An HTML element is an Element whose namespace is the HTML namespace."
//
// I allow an extra argument to more easily check whether something is a
-// particular HTML element, like isHtmlElement(node, "OL").
-function isHtmlElement(node, tag) {
+// particular HTML element, like isHtmlElement(node, "OL"). It accepts arrays
+// too, like isHtmlElement(node, ["OL", "UL"]) to check if it's an ol or ul.
+function isHtmlElement(node, tags) {
+ if (typeof tags == "string") {
+ tags = [tags];
+ }
return node
&& node.nodeType == Node.ELEMENT_NODE
&& isHtmlNamespace(node.namespaceURI)
- && (typeof tag == "undefined" || node.tagName == tag);
+ && (typeof tags == "undefined" || tags.indexOf(node.tagName) != -1);
}
// "An inline node is either a Text node, or an Element whose "display"
@@ -506,50 +510,78 @@
function wrap(nodeList, siblingCriteria, newParentInstructions) {
// "If node list is empty, or the first member of node list is not
- // editable, abort these steps."
+ // editable, return null and abort these steps."
if (!nodeList.length
|| !isEditable(nodeList[0])) {
- return;
+ return null;
}
+ // "Let original parent be the parent of the first member of node list."
+ var originalParent = nodeList[0].parentNode;
+
// "If the previousSibling of the first member of node list is editable and
- // meets the sibling criteria, then for each node in node list, append node
- // as the last child of its previousSibling, preserving ranges. Then abort
- // these steps."
+ // meets the sibling criteria:"
if (isEditable(nodeList[0].previousSibling)
&& siblingCriteria(nodeList[0].previousSibling)) {
+ // "For each node in node list, append node as the last child of its
+ // previousSibling, preserving ranges."
for (var i = 0; i < nodeList.length; i++) {
movePreservingRanges(nodeList[i], nodeList[i].previousSibling, -1);
}
- return;
+
+ // "If original parent is editable and has no children, remove it from
+ // its parent."
+ if (isEditable(originalParent)
+ && !originalParent.hasChildNodes()) {
+ originalParent.parentNode.removeChild(originalParent);
+ }
+
+ // "Return the parent of the first member of node list and abort these
+ // steps."
+ return nodeList[0].parentNode;
}
// "If the nextSibling of the last member of node list is editable and
- // meets the sibling criteria, then for each node in node list, in reverse
- // order, insert node as the first child of its nextSibling, preserving
- // ranges. Then abort these steps."
+ // meets the sibling criteria:"
if (isEditable(nodeList[nodeList.length - 1].nextSibling)
&& siblingCriteria(nodeList[nodeList.length - 1].nextSibling)) {
+ // "For each node in node list, in reverse order, insert node as the
+ // first child of its nextSibling, preserving ranges."
for (var i = nodeList.length - 1; i >= 0; i--) {
movePreservingRanges(nodeList[i], nodeList[i].nextSibling, 0);
}
- return;
+
+ // "If original parent is editable and has no children, remove it from
+ // its parent."
+ if (isEditable(originalParent)
+ && !originalParent.hasChildNodes()) {
+ originalParent.parentNode.removeChild(originalParent);
+ }
+
+ // "Return the parent of the first member of node list and abort these
+ // steps."
+ return nodeList[0].parentNode;
}
// "Run the new parent instructions, and let new parent be the result."
var newParent = newParentInstructions();
- // "If new parent cannot be the child of the parent of the first member of
- // node list, split the parent of node list."
+ // "If new parent's parent is null, and new parent cannot be the child of
+ // the parent of the first member of node list, split the parent of node
+ // list."
//
// Hack for now, as usual. Don't use this for inline elements!
- if (isHtmlElement(nodeList[0].parentNode, "P")) {
+ if (!newParent.parentNode
+ && isHtmlElement(nodeList[0].parentNode, "P")) {
splitParent(nodeList);
}
- // "Insert new parent into the parent of the first member of node list
- // immediately before the first member of node list."
- nodeList[0].parentNode.insertBefore(newParent, nodeList[0]);
+ // "If new parent's parent is null, insert new parent into the parent of
+ // the first member of node list immediately before the first member of
+ // node list."
+ if (!newParent.parentNode) {
+ nodeList[0].parentNode.insertBefore(newParent, nodeList[0]);
+ }
// "For each node in node list, append node as the last child of new
// parent, preserving ranges."
@@ -557,8 +589,18 @@
movePreservingRanges(nodeList[i], newParent, -1);
}
+ // "If original parent is editable and has no children, remove it from its
+ // parent."
+ if (isEditable(originalParent)
+ && !originalParent.hasChildNodes()) {
+ originalParent.parentNode.removeChild(originalParent);
+ }
+
// "Remove extraneous line breaks from new parent."
removeExtraneousLineBreaks(newParent);
+
+ // "Return new parent."
+ return newParent;
}
function removeExtraneousLineBreaks(node) {
@@ -2614,25 +2656,30 @@
// "While node list is not empty:"
while (nodeList.length) {
- // "Let sublist be an empty list of nodes."
- var sublist = [];
-
- // "Remove the first member of node list and append it to sublist."
- sublist.push(nodeList.shift());
-
- // "If the first member of sublist is an ol, outdent it."
- if (isHtmlElement(sublist[0], "OL")) {
- outdentNode(sublist[0]);
-
- // "Otherwise, if the first member of sublist is a ul, set the tag
- // name of the first member of sublist to "ol"."
- } else if (isHtmlElement(sublist[0], "UL")) {
- setTagName(sublist[0], "ol");
-
- // "Otherwise, if the parent of the first member of sublist is an
- // editable ol:"
- } else if (isHtmlElement(sublist[0].parentNode, "OL")
- && isEditable(sublist[0].parentNode)) {
+ // "Let node be the first member of node list."
+ // "Remove node from node list."
+ var node = nodeList.shift();
+
+ // "If node is an ol, outdent it and continue from the beginning of
+ // this loop."
+ if (isHtmlElement(node, "OL")) {
+ outdentNode(node);
+ continue;
+ }
+
+ // "If node is a ul, set the tag name of node to "ol" and continue
+ // from the beginning of this loop."
+ if (isHtmlElement(node, "UL")) {
+ setTagName(node, "ol");
+ continue;
+ }
+
+ // "Let sublist be a list of nodes, initially consisting of node."
+ var sublist = [node];
+
+ // "If the parent of node is an editable ol:"
+ if (isHtmlElement(node.parentNode, "OL")
+ && isEditable(node.parentNode)) {
// "While node list is not empty, and the first member of node
// list is the nextSibling of the last member of sublist, and
// the first member of node list is not an ol or ul, remove the
@@ -2650,10 +2697,13 @@
// "Fix orphaned list items in sublist."
fixOrphanedListItems(sublist);
- // "Otherwise, if the parent of the first member of sublist is an
- // editable ul:"
- } else if (isHtmlElement(sublist[0].parentNode, "UL")
- && isEditable(sublist[0].parentNode)) {
+ // "Continue from the beginning of this loop."
+ continue;
+ }
+
+ // "If the parent of node is an editable ul:"
+ if (isHtmlElement(node.parentNode, "UL")
+ && isEditable(node.parentNode)) {
// "While node list is not empty, and the first member of node
// list is the nextSibling of the last member of sublist, and
// the first member of node list is not an ol or ul, remove the
@@ -2675,144 +2725,83 @@
function(node) { return isHtmlElement(node, "OL") },
function() { return document.createElement("ol") });
+ // "Continue from the beginning of this loop."
+ continue;
+ }
+
+ // "If node is a p or li or div, set the tag name of node to "li",
+ // and let li be the result."
+ var li;
+ if (isHtmlElement(node, ["P", "LI", "DIV"])) {
+ li = setTagName(node, "li");
+
// "Otherwise:"
} else {
- // "If the first member of sublist is a p or li or div, set the
- // tag name of the first member of sublist to "li", and let li
- // be the result. Remove the first member of sublist, and
- // append li to sublist."
- var li;
- if (isHtmlElement(sublist[0], "P")
- || isHtmlElement(sublist[0], "LI")
- || isHtmlElement(sublist[0], "DIV")) {
- li = setTagName(sublist[0], "LI");
- sublist = [li];
-
- // "Otherwise:"
- } else {
- // "While node list is not empty, and the first member of
- // node list is the nextSibling of the last member of
- // sublist, and the last member of sublist and first member
- // of node list are both inline nodes, and the last member
- // of sublist is not a br, remove the first member from
- // node list and append it to sublist."
- while (nodeList.length
- && nodeList[0] == sublist[sublist.length -1].nextSibling
- && isInlineNode(nodeList[0])
- && isInlineNode(sublist[sublist.length -1])
- && !isHtmlElement(sublist[sublist.length -1], "BR")) {
- sublist.push(nodeList.shift());
- }
-
- // "Let li be the result of calling createElement("li") on
- // the ownerDocument of the first member of sublist."
- var li = sublist[0].ownerDocument.createElement("li");
+ // "While node list is not empty, and the first member of node
+ // list is the nextSibling of the last member of sublist, and
+ // the last member of sublist and first member of node list are
+ // both inline nodes, and the last member of sublist is not a
+ // br, remove the first member from node list and append it to
+ // sublist."
+ while (nodeList.length
+ && nodeList[0] == sublist[sublist.length - 1].nextSibling
+ && isInlineNode(sublist[sublist.length - 1])
+ && isInlineNode(nodeList[0])
+ && !isHtmlElement(sublist[sublist.length - 1], "BR")) {
+ sublist.push(nodeList.shift());
}
- // "If the nextSibling of the last member of sublist is an ol:"
- if (isHtmlElement(sublist[sublist.length - 1].nextSibling, "OL")) {
- // "Insert li as the first child of the nextSibling of the
- // last member of sublist, preserving ranges."
- movePreservingRanges(li, sublist[sublist.length - 1].nextSibling, 0);
-
- // "If the first member of sublist is an li, remove it from
- // sublist."
- if (isHtmlElement(sublist[0], "LI")) {
- sublist.shift();
- }
-
- // "For each node in sublist in reverse order, insert node
- // as the first child of li, preserving ranges."
- for (var i = sublist.length - 1; i >= 0; i--) {
- movePreservingRanges(sublist[i], li, 0);
+ // "Wrap sublist, with sibling criteria matching nothing and
+ // with new parent instructions returning the result of calling
+ // createElement("li") on the context object. Let li be the
+ // result."
+ li = wrap(sublist,
+ function(node) { return false },
+ function() { return document.createElement("li") });
+ }
+
+ // "If li is null, continue from the beginning of this loop."
+ if (!li) {
+ continue;
+ }
+
+ // "Wrap the one-node list consisting of li, with the sibling
+ // criteria matching any ol, and the new parent instructions being
+ // the following:"
+ wrap([li],
+ function(node) { return isHtmlElement(node, "OL") },
+ function() {
+ // "Let original parent be the parent of li."
+ var originalParent = li.parentNode;
+
+ // "If original parent is not an editable indentation
+ // element, or the previousSibling of original parent is
+ // not an editable ol, call createElement("ol") on the
+ // context object and return the result. Otherwise:"
+ if (!isEditable(originalParent)
+ || !isIndentationElement(originalParent)
+ || !isEditable(originalParent.previousSibling)
+ || !isHtmlElement(originalParent.previousSibling, "OL")) {
+ return document.createElement("ol");
}
- // "Otherwise:"
- } else {
- // "Let ol be the previousSibling of the first member of
- // sublist."
- var ol = sublist[0].previousSibling;
-
- // "Let original parent be the parent of the first member
- // of sublist."
- var originalParent = sublist[0].parentNode;
-
- // "If ol is null, and original parent is an editable
- // indentation element, and the previousSibling of original
- // parent is an editable ol:"
- if (!ol
- && isEditable(originalParent)
- && isIndentationElement(originalParent)
- && isEditable(originalParent.previousSibling)
- && isHtmlElement(originalParent.previousSibling, "OL")) {
- // "Let ol be the previousSibling of original parent."
- ol = originalParent.previousSibling;
-
- // "Normalize sublists of ol's last child."
- normalizeSublists(ol.lastChild);
-
- // "If ol's last child is not an editable ol, call
- // createElement("ol") on the ownerDocument of ol, and
- // append the result as the last child of ol."
- if (!isEditable(ol.lastChild)
- || !isHtmlElement(ol.lastChild, "OL")) {
- ol.appendChild(ol.ownerDocument.createElement("ol"));
- }
-
- // "Set ol to its last child."
- ol = ol.lastChild;
+
+ // "Let ol be the previousSibling of original parent."
+ var ol = originalParent.previousSibling;
+
+ // "Normalize sublists of ol's last child."
+ normalizeSublists(ol.lastChild);
+
+ // "If ol's last child is not an editable ol, call
+ // createElement("ol") on the context object, and append
+ // the result as the last child of ol."
+ if (!isEditable(ol.lastChild)
+ || !isHtmlElement(ol.lastChild, "OL")) {
+ ol.appendChild(document.createElement("ol"));
}
- // "If ol is not an editable ol:
- if (!isEditable(ol)
- || !isHtmlElement(ol, "OL")) {
- // "If original parent is a p, split the parent of
- // sublist, with new parent null, and then set original
- // parent to the parent of the first member of
- // sublist."
- if (isHtmlElement(originalParent, "P")) {
- splitParent(sublist);
-
- originalParent = sublist[0].parentNode;
- }
-
- // "Let ol be the result of calling createElement("ol")
- // on the ownerDocument of the first member of
- // sublist."
- ol = sublist[0].ownerDocument.createElement("ol");
-
- // "Insert ol into original parent immediately before
- // the first member of sublist."
- originalParent.insertBefore(ol, sublist[0]);
- }
-
- // "Append li as the last child of ol, preserving ranges."
- movePreservingRanges(li, ol, ol.childNodes.length);
-
- // "If the first member of sublist is an li, remove it from
- // sublist."
- if (isHtmlElement(sublist[0], "LI")) {
- sublist.shift();
- }
-
- // "For each node in sublist, append node as the last child
- // of li, preserving ranges."
- for (var i = 0; i < sublist.length; i++) {
- movePreservingRanges(sublist[i], li, li.childNodes.length);
- }
-
- // "If original parent has no children, remove it from its
- // parent."
- if (!originalParent.hasChildNodes()) {
- originalParent.parentNode.removeChild(originalParent);
- }
- }
- }
-
- // "Remove extraneous line breaks from ol."
- removeExtraneousLineBreaks(ol);
-
- // "Remove extraneous line breaks from li."
- removeExtraneousLineBreaks(li);
+ // "Return the last child of ol."
+ return ol.lastChild;
+ });
}
break;
--- a/source.html Tue May 17 14:03:31 2011 -0600
+++ b/source.html Tue May 17 14:47:39 2011 -0600
@@ -365,38 +365,64 @@
<ol>
<li>If <var>node list</var> is empty, or the first member of <var>node
- list</var> is not <span>editable</span>, abort these steps.
+ list</var> is not <span>editable</span>, return null and abort these steps.
+
+ <li>Let <var>original parent</var> be the [[parent]] of the first member of
+ <var>node list</var>.
<li>If the [[previoussibling]] of the first member of <var>node list</var>
- is <span>editable</span> and meets the <span>sibling criteria</span>, then
- for each <var>node</var> in <var>node list</var>, append <var>node</var> as
- the last [[child]] of its [[previoussibling]], <span>preserving
- ranges</span>. Then abort these steps.
+ is <span>editable</span> and meets the <span>sibling criteria</span>:
+
+ <ol>
+ <li>For each <var>node</var> in <var>node list</var>, append
+ <var>node</var> as the last [[child]] of its [[previoussibling]],
+ <span>preserving ranges</span>.
+
+ <li>If <var>original parent</var> is <span>editable</span> and has no
+ [[children]], remove it from its [[parent]].
+
+ <li>Return the [[parent]] of the first member of <var>node list</var> and
+ abort these steps.
+ </ol>
<li>If the [[nextsibling]] of the last member of <var>node list</var> is
- <span>editable</span> and meets the <span>sibling criteria</span>, then for
- each <var>node</var> in <var>node list</var>, <em>in reverse order</em>,
- insert <var>node</var> as the first [[child]] of its [[nextsibling]],
- <span>preserving ranges</span>. Then abort these steps.
+ <span>editable</span> and meets the <span>sibling criteria</span>:
+
+ <ol>
+ <li>For each <var>node</var> in <var>node list</var>, <em>in reverse
+ order</em>, insert <var>node</var> as the first [[child]] of its
+ [[nextsibling]], <span>preserving ranges</span>.
+
+ <li>If <var>original parent</var> is <span>editable</span> and has no
+ [[children]], remove it from its [[parent]].
+
+ <li>Return the [[parent]] of the first member of <var>node list</var> and
+ abort these steps.
+ </ol>
<li>Run the <span>new parent instructions</span>, and let <var>new
parent</var> be the result.
- <li>If <var>new parent</var> cannot be the [[child]] of the [[parent]] of the
- first member of <var>node list</var>, <span>split the parent</span> of
- <var>node list</var>.
+ <li>If <var>new parent</var>'s [[parent]] is null, and <var>new parent</var>
+ cannot be the [[child]] of the [[parent]] of the first member of <var>node
+ list</var>, <span>split the parent</span> of <var>node list</var>.
<p class=XXX>"Cannot be the child" needs to be defined.
- <li>Insert <var>new parent</var> into the [[parent]] of the first member of
- <var>node list</var> immediately before the first member of <var>node
- list</var>.
+ <li>If <var>new parent</var>'s [[parent]] is null, insert <var>new
+ parent</var> into the [[parent]] of the first member of <var>node list</var>
+ immediately before the first member of <var>node list</var>.
<li>For each <var>node</var> in <var>node list</var>, append <var>node</var>
as the last [[child]] of <var>new parent</var>, <span>preserving
ranges</span>.
+ <li>If <var>original parent</var> is <span>editable</span> and has no
+ [[children]], remove it from its [[parent]].
+
<li><span>Remove extraneous line breaks</span> from <var>new parent</var>.
+
+ <li>Return <var>new parent</var>.
</ol>
<p>To <dfn>remove extraneous line breaks</dfn> from a [[node]] <var>node</var>:
@@ -2808,20 +2834,21 @@
<li>While <var>node list</var> is not empty:
<ol>
- <li>Let <var>sublist</var> be an empty list of [[nodes]].
-
- <li>Remove the first member of <var>node list</var> and append it to
- <var>sublist</var>.
-
- <li>If the first member of <var>sublist</var> is an [[ol]],
- <span>outdent</span> it.
-
- <li>Otherwise, if the first member of <var>sublist</var> is a [[ul]],
- <span>set the tag name</span> of the first member of <var>sublist</var> to
- "ol".
-
- <li>Otherwise, if the [[parent]] of the first member of <var>sublist</var>
- is an <span>editable</span> [[ol]]:
+ <li>Let <var>node</var> be the first member of <var>node list</var>.
+
+ <li>Remove <var>node</var> from <var>node list</var>.
+
+ <li>If <var>node</var> is an [[ol]], <span>outdent</span> it and continue
+ from the beginning of this loop.
+
+ <li>If <var>node</var> is a [[ul]], <span>set the tag name</span> of
+ <var>node</var> to "ol" and continue from the beginning of this loop.
+
+ <li>Let <var>sublist</var> be a list of [[nodes]], initially consisting of
+ <var>node</var>.
+
+ <li>If the [[parent]] of <var>node</var> is an <span>editable</span>
+ [[ol]]:
<!-- Outdent -->
<ol>
@@ -2834,10 +2861,12 @@
<li><span>Split the parent</span> of <var>sublist</var>.
<li><span>Fix orphaned list items</span> in <var>sublist</var>.
+
+ <li>Continue from the beginning of this loop.
</ol>
- <li>Otherwise, if the [[parent]] of the first member of <var>sublist</var>
- is an <span>editable</span> [[ul]]:
+ <li>If the [[parent]] of <var>node</var> is an <span>editable</span>
+ [[ul]]:
<!-- Split up the parent -->
<ol>
@@ -2855,119 +2884,66 @@
data-anolis-spec=domcore
title=dom-Document-createElement>createElement("ol")</code> on the
[[contextobject]].
+
+ <li>Continue from the beginning of this loop.
</ol>
- <li>Otherwise:
<!-- General case. Add an ol wrapper for each line. <br> breaks apart
<li>'s, and multiple consecutive <br>s or trailing <br>s become empty
<li>s. -->
+ <li>If <var>node</var> is a [[p]] or [[li]] or [[div]], <span>set the tag
+ name</span> of <var>node</var> to "li", and let <var>li</var> be the
+ result.
+
+ <li>Otherwise:
+
<ol>
- <li>If the first member of <var>sublist</var> is a [[p]] or [[li]] or
- [[div]], <span>set the tag name</span> of the first member of
- <var>sublist</var> to "li", and let <var>li</var> be the result. Remove
- the first member of <var>sublist</var>, and append <var>li</var> to
+ <li>While <var>node list</var> is not empty, and the first member of
+ <var>node list</var> is the [[nextsibling]] of the last member of
+ <var>sublist</var>, and the last member of <var>sublist</var> and first
+ member of <var>node list</var> are both <span title="inline node">inline
+ nodes</span>, and the last member of <var>sublist</var> is not a [[br]],
+ remove the first member from <var>node list</var> and append it to
<var>sublist</var>.
- <li>Otherwise:
-
- <ol>
- <li>While <var>node list</var> is not empty, and the first member of
- <var>node list</var> is the [[nextsibling]] of the last member of
- <var>sublist</var>, and the last member of <var>sublist</var> and first
- member of <var>node list</var> are both <span title="inline
- node">inline nodes</span>, and the last member of <var>sublist</var> is
- not a [[br]], remove the first member from <var>node list</var> and
- append it to <var>sublist</var>.
-
- <li>Let <var>li</var> be the result of calling <code
- data-anolis-spec=domcore
- title=dom-Document-createElement>createElement("li")</code> on the
- [[ownerdocument]] of the first member of <var>sublist</var>.
- </ol>
-
- <li>If the [[nextsibling]] of the last member of <var>sublist</var> is an
- [[ol]]:
-
- <ol>
- <li>Insert <var>li</var> as the first [[child]] of the [[nextsibling]]
- of the last member of <var>sublist</var>, <span>preserving
- ranges</span>.
-
- <li>If the first member of <var>sublist</var> is an [[li]], remove it
- from <var>sublist</var>.
-
- <li>For each <var>node</var> in <var>sublist</var> <em>in reverse
- order</em>, insert <var>node</var> as the first [[child]] of
- <var>li</var>, <span>preserving ranges</span>.
- </ol>
-
- <li>Otherwise:
-
- <ol>
- <li>Let <var>ol</var> be the [[previoussibling]] of the first member of
- <var>sublist</var>.
-
- <li>Let <var>original parent</var> be the [[parent]] of the first
- member of <var>sublist</var>.
-
- <li>If <var>ol</var> is null, and <var>original parent</var> is an
- <span>editable</span> <span>indentation element</span>, and the
- [[previoussibling]] of <var>original parent</var> is an
- <span>editable</span> [[ol]]:
-
- <ol>
- <li>Let <var>ol</var> be the [[previoussibling]] of <var>original
- parent</var>.
-
- <li><span>Normalize sublists</span> of <var>ol</var>'s last [[child]].
-
- <li>If <var>ol</var>'s last [[child]] is not an <span>editable</span>
- [[ol]], call <code data-anolis-spec=domcore
- title=dom-Document-createElement>createElement("ol")</code> on the
- [[ownerdocument]] of <var>ol</var>, and append the result as the last
- [[child]] of <var>ol</var>.
-
- <li>Set <var>ol</var> to its last [[child]].
- </ol>
-
- <li>If <var>ol</var> is not an <span>editable</span> [[ol]]:
-
- <ol>
- <li>If <var>original parent</var> is a [[p]], <span>split the
- parent</span> of <var>sublist</var>, and then set <var>original
- parent</var> to the [[parent]] of the first member of
- <var>sublist</var>.
-
- <li>Let <var>ol</var> be the result of calling <code
- data-anolis-spec=domcore
- title=dom-Document-createElement>createElement("ol")</code> on the
- [[ownerdocument]] of the first member of <var>sublist</var>.
-
- <li>Insert <var>ol</var> into <var>original parent</var> immediately
- before the first member of <var>sublist</var>.
- </ol>
-
- <li>Append <var>li</var> as the last [[child]] of <var>ol</var>,
- <span>preserving ranges</span>.
-
- <li>If the first member of <var>sublist</var> is an [[li]], remove it
- from <var>sublist</var>.
-
- <li>For each <var>node</var> in <var>sublist</var>, append
- <var>node</var> as the last [[child]] of <var>li</var>,
- <span>preserving ranges</span>.
-
- <li>If <var>original parent</var> has no [[children]], remove it from
- its [[parent]].
- <!-- This might happen if it's an indentation element whose previous
- sibling is an ol, for instance. -->
- </ol>
+ <li><span>Wrap</span> <var>sublist</var>, with <span>sibling
+ criteria</span> matching nothing and with <span>new parent
+ instructions</span> returning the result of calling <code
+ data-anolis-spec=domcore
+ title=dom-Document-createElement>createElement("li")</code> on the
+ [[contextobject]]. Let <var>li</var> be the result.
</ol>
- <li><span>Remove extraneous line breaks</span> from <var>ol</var>.
-
- <li><span>Remove extraneous line breaks</span> from <var>li</var>.
+ <li>If <var>li</var> is null, continue from the beginning of this loop.
+
+ <li><span>Wrap</span> the one-[[node]] list consisting of <var>li</var>,
+ with the <span>sibling criteria</span> matching any [[ol]], and the
+ <span>new parent instructions</span> being the following:
+
+ <ol>
+ <li>Let <var>original parent</var> be the [[parent]] of <var>li</var>.
+
+ <li>If <var>original parent</var> is not an <span>editable</span>
+ <span>indentation element</span>, or the [[previoussibling]] of
+ <var>original parent</var> is not an <span>editable</span> [[ol]], call
+ <code data-anolis-spec=domcore
+ title=dom-Document-createElement>createElement("ol")</code> on the
+ [[contextobject]] and return the result. Otherwise:
+
+ <li>Let <var>ol</var> be the [[previoussibling]] of <var>original
+ parent</var>.
+
+ <li><span>Normalize sublists</span> of <var>ol</var>'s last [[child]].
+
+ <li>If <var>ol</var>'s last [[child]] is not an <span>editable</span>
+ [[ol]], call <code data-anolis-spec=domcore
+ title=dom-Document-createElement>createElement("ol")</code> on the
+ [[contextobject]], and append the result as the last [[child]] of
+ <var>ol</var>.
+
+ <li>Return the last [[child]] of <var>ol</var>.
+ </ol>
</ol>
</ol>