Fix another br-related bug
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Sun, 29 May 2011 15:48:24 -0600
changeset 190 ba77f9116ec3
parent 189 7e493872a90f
child 191 924539fdd89d
Fix another br-related bug

This is totally untenable, there are going to be zillions more like
these. There must be a better way. But save that for later.
editcommands.html
implementation.js
source.html
--- a/editcommands.html	Sun May 29 15:38:52 2011 -0600
+++ b/editcommands.html	Sun May 29 15:48:24 2011 -0600
@@ -581,10 +581,11 @@
   list</var>, <a href=#remove-extraneous-line-breaks-before>remove extraneous line breaks before</a> <var title="">original
   parent</var>.
 
-  <li>If 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="">original parent</var> is in <var title="">node
-  list</var>, and <var title="">original parent</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> and
-  <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> are both <a href=#inline-node title="inline node">inline nodes</a>, 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("br")</a></code> on the
+  <li>If <var title="">original parent</var> is not an <a href=#inline-node>inline node</a>, and 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="">original parent</var> is in <var title="">node list</var>, and
+  <var title="">original parent</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> and <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> are both
+  <a href=#inline-node title="inline node">inline nodes</a>, and <var title="">original
+  parent</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 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>, 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("br")</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="">original parent</var>, then insert the result 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="">original parent</var> immediately after <var title="">original
   parent</var>.
--- a/implementation.js	Sun May 29 15:38:52 2011 -0600
+++ b/implementation.js	Sun May 29 15:48:24 2011 -0600
@@ -466,14 +466,17 @@
 		removeExtraneousLineBreaksBefore(originalParent);
 	}
 
-	// "If the last child of original parent is in node list, and original
-	// parent's last child and nextSibling are both inline nodes, call
-	// createElement("br") on the ownerDocument of original parent, then insert
-	// the result into the parent of original parent immediately after original
-	// parent."
-	if (nodeList.indexOf(originalParent.lastChild) != -1
+	// "If original parent is not an inline node, and the last child of
+	// original parent is in node list, and original parent's last child and
+	// nextSibling are both inline nodes, and original parent's last child is
+	// not a br, call createElement("br") on the ownerDocument of original
+	// parent, then insert the result into the parent of original parent
+	// immediately after original parent."
+	if (!isInlineNode(originalParent)
+	&& nodeList.indexOf(originalParent.lastChild) != -1
 	&& isInlineNode(originalParent.lastChild)
-	&& isInlineNode(originalParent.nextSibling)) {
+	&& isInlineNode(originalParent.nextSibling)
+	&& !isHtmlElement(originalParent.lastChild, "br")) {
 		originalParent.parentNode.insertBefore(originalParent.ownerDocument.createElement("br"), originalParent.nextSibling);
 	}
 
--- a/source.html	Sun May 29 15:38:52 2011 -0600
+++ b/source.html	Sun May 29 15:48:24 2011 -0600
@@ -536,10 +536,12 @@
   list</var>, <span>remove extraneous line breaks before</span> <var>original
   parent</var>.
 
-  <li>If the last [[child]] of <var>original parent</var> is in <var>node
-  list</var>, and <var>original parent</var>'s last [[child]] and
-  [[nextsibling]] are both <span title="inline node">inline nodes</span>, call
-  <code data-anolis-spec=domcore
+  <li>If <var>original parent</var> is not an <span>inline node</span>, and the
+  last [[child]] of <var>original parent</var> is in <var>node list</var>, and
+  <var>original parent</var>'s last [[child]] and [[nextsibling]] are both
+  <span title="inline node">inline nodes</span>, and <var>original
+  parent</var>'s last [[child]] is not a [[br]], call <code
+  data-anolis-spec=domcore
   title=dom-Document-createElement>createElement("br")</code> on the
   [[ownerdocument]] of <var>original parent</var>, then insert the result into
   the [[parent]] of <var>original parent</var> immediately after <var>original