Test/document insertHTML on whitespace
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Wed, 13 Jul 2011 09:57:35 -0600
changeset 413 874af72e14e0
parent 412 acbbdc6ca892
child 414 9a713f0b9db4
Test/document insertHTML on whitespace
editcommands.html
source.html
tests.js
--- a/editcommands.html	Wed Jul 13 09:39:59 2011 -0600
+++ b/editcommands.html	Wed Jul 13 09:57:35 2011 -0600
@@ -6177,6 +6177,16 @@
 
   <li>Call <code class=external data-anolis-spec=domrange title=dom-Range-insertNode><a href=http://html5.org/specs/dom-range.html#dom-range-insertnode>insertNode(<var title="">frag</var>)</a></code> on the <a href=#active-range>active range</a>.
 
+  <!--
+  We could canonicalize whitespace at this point, but let's not.  If the author
+  wants HTML, give them HTML behavior.  When asked to replace a paragraph's
+  contents with a single space, Firefox 7.0a2 does so but inserts a <br> before
+  it (not after); Chrome 14 dev does so and doesn't insert a <br>, so the
+  paragraph collapses; Opera 11.50 doesn't insert the space at all, and just
+  inserts a <br>.  Correct behavior is to insert a space, then insert a <br>
+  after it in the next step because it's an invisible node.
+  -->
+
   <li>If the <a href=#active-range>active range</a>'s <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-range-start title=concept-range-start>start</a> <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-boundary-point-node title=concept-boundary-point-node>node</a> is a <a href=#block-node>block
   node</a> with no <a href=#visible>visible</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>children</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 <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a> and append the result as the
--- a/source.html	Wed Jul 13 09:39:59 2011 -0600
+++ b/source.html	Wed Jul 13 09:57:35 2011 -0600
@@ -6172,6 +6172,16 @@
 
   <li>Call [[insertnode|<var>frag</var>]] on the <span>active range</span>.
 
+  <!--
+  We could canonicalize whitespace at this point, but let's not.  If the author
+  wants HTML, give them HTML behavior.  When asked to replace a paragraph's
+  contents with a single space, Firefox 7.0a2 does so but inserts a <br> before
+  it (not after); Chrome 14 dev does so and doesn't insert a <br>, so the
+  paragraph collapses; Opera 11.50 doesn't insert the space at all, and just
+  inserts a <br>.  Correct behavior is to insert a space, then insert a <br>
+  after it in the next step because it's an invisible node.
+  -->
+
   <li>If the <span>active range</span>'s [[startnode]] is a <span>block
   node</span> with no <span>visible</span> [[children]], call
   [[createelement|"br"]] on the [[contextobject]] and append the result as the
--- a/tests.js	Wed Jul 13 09:39:59 2011 -0600
+++ b/tests.js	Wed Jul 13 09:57:35 2011 -0600
@@ -1659,7 +1659,9 @@
 		['', 'foo[bar]baz'],
 		['\0', 'foo[bar]baz'],
 		['\x07', 'foo[bar]baz'],
-		['\ud800', 'foo[bar]baz'],
+		// The following line makes Firefox 7.0a2 go into an infinite loop on
+		// my machine.
+		//['\ud800', 'foo[bar]baz'],
 
 		['<b>', 'foo[bar]baz'],
 		['<b>abc', 'foo[bar]baz'],
@@ -1711,6 +1713,7 @@
 		['<p>abc', '<font color=red>foo[]bar</font>'],
 		['<p>abc', '<span style=color:red>foo[]bar</span>'],
 		['<p>abc', '<span style=font-variant:small-caps>foo[]bar</span>'],
+		[' ', '<p>[foo]</p>'],
 		['<span style=display:none></span>', '<p>[foo]</p>'],
 		['<!--abc-->', '<p>[foo]</p>'],
 	],