Nest lists in other lists, for simplicity
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Thu, 05 May 2011 12:00:19 -0600
changeset 86 667696ef2073
parent 85 d94c0062e53c
child 87 b5cb0161423b
Nest lists in other lists, for simplicity
editcommands.html
implementation.js
source.html
--- a/editcommands.html	Tue May 03 15:56:36 2011 -0600
+++ b/editcommands.html	Thu May 05 12:00:19 2011 -0600
@@ -27,7 +27,7 @@
 <body class=draft>
 <div class=head id=head>
 <h1>HTML Editing Commands</h1>
-<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-3-may-2011>Work in Progress &mdash; Last Update 3 May 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-5-may-2011>Work in Progress &mdash; Last Update 5 May 2011</h2>
 <dl>
  <dt>Editor
  <dd>Aryeh Gregor &lt;ayg+spec@aryeh.name&gt;
@@ -1957,16 +1957,28 @@
     <li>Let <var title="">new parent</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(<var title="">tag</var>)</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="">node</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 <var title="">node</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>, append
-    <var title="">new parent</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 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="">node</var>.
-    <!-- This matches Opera 11.10.  IE9, Firefox 4.0, and Chrome 12 dev all add
-    the new list element as a child of the parent list unconditionally.
-    There's no visible difference, but Opera's version is conforming (and makes
-    more semantic sense). -->
-
-    <li>Otherwise, 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
-    <var title="">node</var> immediately before <var title="">node</var>.
+    <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 <var title="">node</var>
+    immediately before <var title="">node</var>.
+    <!--
+    This matches IE9, Firefox 4.0, and Chrome 12 dev.  If there's a preceding
+    <li>, Opera 11.10 instead adds the new parent to the end of that <li>, so
+    it's not the child of another list, which is invalid.  But the other
+    browsers' way of doing things makes things simpler.  E.g., if we want to
+    indent an <li> and it has <ol>/<ul> children, we have to distinguish
+    between the case where we want to indent the whole <li> or only the first
+    part.  It also allows things like
+
+      <ol><li>
+        foo
+        <ol><li>bar</li></ol>
+        baz
+      </li></ol>
+
+    in which case it's unclear what we should do if the user selects "foo" and
+    indents.  I've filed a bug on HTML5:
+
+    http://www.w3.org/Bugs/Public/show_bug.cgi?id=12609
+    -->
 
     <li>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>.
--- a/implementation.js	Tue May 03 15:56:36 2011 -0600
+++ b/implementation.js	Thu May 05 12:00:19 2011 -0600
@@ -2552,17 +2552,8 @@
 		// ownerDocument of node."
 		var newParent = node.ownerDocument.createElement(tag);
 
-		// "If the previousSibling of node is an li, append new parent as the
-		// last child of the previousSibling of node."
-		if (isHtmlElement(node.previousSibling)
-		&& node.previousSibling.tagName == "LI") {
-			node.previousSibling.appendChild(newParent);
-
-		// "Otherwise, insert new parent into the parent of node immediately
-		// before node."
-		} else {
-			node.parentNode.insertBefore(newParent, node);
-		}
+		// "Insert new parent into the parent of node immediately before node."
+		node.parentNode.insertBefore(newParent, node);
 
 		// "Append node as the last child of new parent, preserving ranges."
 		movePreservingRanges(node, newParent, 0);
--- a/source.html	Tue May 03 15:56:36 2011 -0600
+++ b/source.html	Thu May 05 12:00:19 2011 -0600
@@ -1977,16 +1977,28 @@
     title=dom-Document-createElement>createElement(<var>tag</var>)</code> on
     the [[ownerdocument]] of <var>node</var>.
 
-    <li>If the [[previoussibling]] of <var>node</var> is an [[li]], append
-    <var>new parent</var> as the last [[child]] of the [[previoussibling]] of
-    <var>node</var>.
-    <!-- This matches Opera 11.10.  IE9, Firefox 4.0, and Chrome 12 dev all add
-    the new list element as a child of the parent list unconditionally.
-    There's no visible difference, but Opera's version is conforming (and makes
-    more semantic sense). -->
-
-    <li>Otherwise, insert <var>new parent</var> into the [[parent]] of
-    <var>node</var> immediately before <var>node</var>.
+    <li>Insert <var>new parent</var> into the [[parent]] of <var>node</var>
+    immediately before <var>node</var>.
+    <!--
+    This matches IE9, Firefox 4.0, and Chrome 12 dev.  If there's a preceding
+    <li>, Opera 11.10 instead adds the new parent to the end of that <li>, so
+    it's not the child of another list, which is invalid.  But the other
+    browsers' way of doing things makes things simpler.  E.g., if we want to
+    indent an <li> and it has <ol>/<ul> children, we have to distinguish
+    between the case where we want to indent the whole <li> or only the first
+    part.  It also allows things like
+
+      <ol><li>
+        foo
+        <ol><li>bar</li></ol>
+        baz
+      </li></ol>
+
+    in which case it's unclear what we should do if the user selects "foo" and
+    indents.  I've filed a bug on HTML5:
+
+    http://www.w3.org/Bugs/Public/show_bug.cgi?id=12609
+    -->
 
     <li>Append <var>node</var> as the last [[child]] of <var>new parent</var>,
     <span>preserving ranges</span>.