li handling
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Sun, 29 May 2011 14:21:59 -0600
changeset 184 593863f0275e
parent 183 c879b966938b
child 185 a2c816de561d
li handling
autoimplementation.html
editcommands.html
implementation.js
linebreaktest.html
source.html
--- a/autoimplementation.html	Sun May 29 13:55:14 2011 -0600
+++ b/autoimplementation.html	Sun May 29 14:21:59 2011 -0600
@@ -1160,7 +1160,16 @@
 		'<pre>foo[]<br></pre>',
 		'<pre>foo[]bar</pre>',
 
+		'<ol><li>{}<br></li></ol>',
+		'foo<ol><li>{}<br></li></ol>',
+		'<ol><li>{}<br></li></ol>foo',
 		'<ol><li>foo<li>{}<br></ol>',
+		'<ol><li>{}<br><li>bar</ol>',
+		'<ol><li>foo</li><ul><li>{}<br></ul></ol>',
+
+		'<dl><dt>{}<br></dt></dl>',
+		'<dl><dt>foo<dd>{}<br></dl>',
+		'<dl><dt>{}<br><dd>bar</dl>',
 
 		'<h1>foo[bar</h1><p>baz]quz</p>',
 		'<p>foo[bar</p><h1>baz]quz</h1>',
--- a/editcommands.html	Sun May 29 13:55:14 2011 -0600
+++ b/editcommands.html	Sun May 29 14:21:59 2011 -0600
@@ -617,6 +617,10 @@
 
   <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>.
+
+  <li>If <var title="">node list</var>'s last member's <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> is null,
+  <a href=#remove-extraneous-line-breaks-at-the-end-of>remove extraneous line breaks at the end of</a> <var title="">node
+  list</var>'s last member'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>.
 </ol>
 
 <p>To remove 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> while <dfn id=preserving-its-descendants>preserving its
@@ -4230,6 +4234,22 @@
     <!-- Necessary because adding a br to the end of a block element does
     nothing. -->
 
+    <p class=XXX>Need to handle the case where there are two consecutive br's
+    at the end of the block.
+
+    <li>Abort these steps.
+  </ol>
+
+  <li>If <var title="">container</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>, and either it 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>
+  or it has a single <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> and that <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 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>:
+
+  <ol>
+    <li><a href=#split-the-parent>Split the parent</a> of 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="">container</var>.
+
+    <li><a href=#fix-orphaned-list-items>Fix orphaned list items</a> in 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="">container</var>.
+
     <li>Abort these steps.
   </ol>
 
--- a/implementation.js	Sun May 29 13:55:14 2011 -0600
+++ b/implementation.js	Sun May 29 14:21:59 2011 -0600
@@ -541,6 +541,12 @@
 	if (!originalParent.hasChildNodes()) {
 		originalParent.parentNode.removeChild(originalParent);
 	}
+
+	// "If node list's last member's nextSibling is null, remove extraneous
+	// line breaks at the end of node list's last member's parent."
+	if (!nodeList[nodeList.length - 1].nextSibling) {
+		removeExtraneousLineBreaksAtTheEndOf(nodeList[nodeList.length - 1].parentNode);
+	}
 }
 
 // "To remove a node node while preserving its descendants, split the parent of
@@ -3284,6 +3290,23 @@
 			return;
 		}
 
+		// "If container is an li, and either it has no children or it has a
+		// single child and that child is a br:"
+		if (isHtmlElement(container, "li")
+		&& (!container.hasChildNodes()
+		|| (container.childNodes.length == 1
+		&& isHtmlElement(container.firstChild, "br")))) {
+			// "Split the parent of the one-node list consisting of container."
+			splitParent([container]);
+
+			// "Fix orphaned list items in the one-node list consisting of
+			// container."
+			fixOrphanedListItems([container]);
+
+			// "Abort these steps."
+			return;
+		}
+
 		// "Let new line range be a new range whose start is the same as
 		// range's, and whose end is (container, length of container)."
 		var newLineRange = document.createRange();
--- a/linebreaktest.html	Sun May 29 13:55:14 2011 -0600
+++ b/linebreaktest.html	Sun May 29 14:21:59 2011 -0600
@@ -136,7 +136,16 @@
 	'<pre>foo[]<br></pre>',
 	'<pre>foo[]bar</pre>',
 
+	'<ol><li>{}<br></li></ol>',
+	'foo<ol><li>{}<br></li></ol>',
+	'<ol><li>{}<br></li></ol>foo',
 	'<ol><li>foo<li>{}<br></ol>',
+	'<ol><li>{}<br><li>bar</ol>',
+	'<ol><li>foo</li><ul><li>{}<br></ul></ol>',
+
+	'<dl><dt>{}<br></dt></dl>',
+	'<dl><dt>foo<dd>{}<br></dl>',
+	'<dl><dt>{}<br><dd>bar</dl>',
 
 	'<h1>foo[bar</h1><p>baz]quz</p>',
 	'<p>foo[bar</p><h1>baz]quz</h1>',
--- a/source.html	Sun May 29 13:55:14 2011 -0600
+++ b/source.html	Sun May 29 14:21:59 2011 -0600
@@ -575,6 +575,10 @@
 
   <li>If <var>original parent</var> has no [[children]], remove it from its
   [[parent]].
+
+  <li>If <var>node list</var>'s last member's [[nextsibling]] is null,
+  <span>remove extraneous line breaks at the end of</span> <var>node
+  list</var>'s last member's [[parent]].
 </ol>
 
 <p>To remove a [[node]] <var>node</var> while <dfn>preserving its
@@ -4265,6 +4269,22 @@
     <!-- Necessary because adding a br to the end of a block element does
     nothing. -->
 
+    <p class=XXX>Need to handle the case where there are two consecutive br's
+    at the end of the block.
+
+    <li>Abort these steps.
+  </ol>
+
+  <li>If <var>container</var> is an [[li]], and either it has no [[children]]
+  or it has a single [[child]] and that [[child]] is a [[br]]:
+
+  <ol>
+    <li><span>Split the parent</span> of the one-[[node]] list consisting of
+    <var>container</var>.
+
+    <li><span>Fix orphaned list items</span> in the one-[[node]] list
+    consisting of <var>container</var>.
+
     <li>Abort these steps.
   </ol>