Fix very silly delete bug
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Sun, 10 Jul 2011 13:03:53 -0600
changeset 388 28676497c4da
parent 387 2302c9ca1b4f
child 389 d440a3a23d11
Fix very silly delete bug

We would break out of a list item when backspacing in some cases even if
not at the beginning of the list item.
editcommands.html
implementation.js
source.html
tests.js
--- a/editcommands.html	Sun Jul 10 12:55:22 2011 -0600
+++ b/editcommands.html	Sun Jul 10 13:03:53 2011 -0600
@@ -5139,7 +5139,7 @@
   expected.
   -->
   <li>If <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> or <code class=external data-anolis-spec=html title="the dt element"><a href=http://www.whatwg.org/html/#the-dt-element>dt</a></code> or <code class=external data-anolis-spec=html title="the dd element"><a href=http://www.whatwg.org/html/#the-dd-element>dd</a></code> and is 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 <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>:
+  <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 <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>, and <var title="">offset</var> is zero:
 
   <ol>
     <li>Let <var title="">items</var> be a list of all <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/html/#the-li-element>li</a></code>s that are
--- a/implementation.js	Sun Jul 10 12:55:22 2011 -0600
+++ b/implementation.js	Sun Jul 10 13:03:53 2011 -0600
@@ -5323,9 +5323,11 @@
 			return;
 		}
 
-		// "If node is an li or dt or dd and is the first child of its parent:"
+		// "If node is an li or dt or dd and is the first child of its parent,
+		// and offset is zero:"
 		if (isHtmlElement(node, ["li", "dt", "dd"])
-		&& node == node.parentNode.firstChild) {
+		&& node == node.parentNode.firstChild
+		&& offset == 0) {
 			// "Let items be a list of all lis that are ancestors of node."
 			//
 			// Remember, must be in tree order.
--- a/source.html	Sun Jul 10 12:55:22 2011 -0600
+++ b/source.html	Sun Jul 10 13:03:53 2011 -0600
@@ -5140,7 +5140,7 @@
   expected.
   -->
   <li>If <var>node</var> is an [[li]] or [[dt]] or [[dd]] and is the first
-  [[child]] of its [[parent]]:
+  [[child]] of its [[parent]], and <var>offset</var> is zero:
 
   <ol>
     <li>Let <var>items</var> be a list of all [[li]]s that are
--- a/tests.js	Sun Jul 10 12:55:22 2011 -0600
+++ b/tests.js	Sun Jul 10 13:03:53 2011 -0600
@@ -366,6 +366,8 @@
 		'<ol><li>foo<li>[]bar<br>baz</ol>',
 		'<ol><li>foo<br>bar<li>[]baz</ol>',
 
+		'<ol><li><p>foo</p>{}bar</ol>',
+
 		'<ol><li><p>foo<li>[]bar</ol>',
 		'<ol><li>foo<li><p>[]bar</ol>',
 		'<ol><li><p>foo<li><p>[]bar</ol>',