Fix still another minor delete bug
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Sun, 12 Jun 2011 12:24:28 -0600
changeset 255 fa08ade96842
parent 254 d68602354ad5
child 256 8fb704c6f76d
Fix still another minor delete bug

Ensures that foo<br><br><table><tr><td>[]bar</table> doesn't strip a
line break, and likewise for <hr>.
editcommands.html
implementation.js
source.html
tests.js
--- a/editcommands.html	Sun Jun 12 12:19:28 2011 -0600
+++ b/editcommands.html	Sun Jun 12 12:24:28 2011 -0600
@@ -2556,6 +2556,16 @@
     to 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 is to avoid stripping a line break
+
+      foo<br><br><table><tr><td>[]bar</table>
+
+    and similarly for <hr>.  We should just do nothing here.
+    -->
+    <li>If 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 <var title="">start node</var> with <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-indexof title=concept-indexof>index</a> <var title="">start
+    offset</var> is a <code class=external data-anolis-spec=html title="the table element"><a href=http://www.whatwg.org/html/#the-table-element>table</a></code>, abort these steps.
+
+    <!--
     Special case:
 
       <p>foo</p><br><p>[]bar</p>
--- a/implementation.js	Sun Jun 12 12:19:28 2011 -0600
+++ b/implementation.js	Sun Jun 12 12:24:28 2011 -0600
@@ -3292,6 +3292,12 @@
 				startNode = startNode.parentNode;
 			}
 
+			// "If the child of start node with index start offset is a table,
+			// abort these steps."
+			if (isHtmlElement(startNode.childNodes[startOffset], "table")) {
+				return;
+			}
+
 			// "If the child of start node with index start offset minus one is
 			// an hr, or the child is a br and the br's previousSibling is
 			// either a br or not an inline node, set node to start node and
--- a/source.html	Sun Jun 12 12:19:28 2011 -0600
+++ b/source.html	Sun Jun 12 12:24:28 2011 -0600
@@ -2536,6 +2536,16 @@
     to its [[parent]].
 
     <!--
+    This is to avoid stripping a line break
+
+      foo<br><br><table><tr><td>[]bar</table>
+
+    and similarly for <hr>.  We should just do nothing here.
+    -->
+    <li>If the [[child]] of <var>start node</var> with [[index]] <var>start
+    offset</var> is a [[table]], abort these steps.
+
+    <!--
     Special case:
 
       <p>foo</p><br><p>[]bar</p>
--- a/tests.js	Sun Jun 12 12:19:28 2011 -0600
+++ b/tests.js	Sun Jun 12 12:24:28 2011 -0600
@@ -284,6 +284,11 @@
 		'<table><tr><td>foo<br><br><td>[]bar</table>',
 		'<table><tr><td>foo<br><br><tr><td>[]bar</table>',
 
+		'foo<hr><table><tr><td>[]bar</table>baz',
+		'foo<table><tr><td>bar<hr></table>[]baz',
+		'<table><tr><td>foo<hr><td>[]bar</table>',
+		'<table><tr><td>foo<hr><tr><td>[]bar</table>',
+
 		// Invisible stuff
 		'foo<span></span>[]bar',
 		'foo<span><span></span></span>[]bar',