--- a/editcommands.html Sun Jul 24 11:38:06 2011 -0600
+++ b/editcommands.html Sun Jul 24 12:01:11 2011 -0600
@@ -3880,11 +3880,24 @@
<li>Remove <var title="">node</var> from <var title="">parent</var>.
- <li>If <var title="">strip wrappers</var> is true, while <var title="">parent</var> is an
- <a href=#editable>editable</a> <a href=#inline-node>inline node</a> with <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-node-length title=concept-node-length>length</a> 0, let
- <var title="">grandparent</var> be 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="">parent</var>, then remove
- <var title="">parent</var> from <var title="">grandparent</var>, then set <var title="">parent</var>
- to <var title="">grandparent</var>.
+ <li>If <var title="">strip wrappers</var> is true or <var title="">parent</var> is not an
+ <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#ancestor-container title="ancestor container">ancestor container</a> of <var title="">start node</var>, while <var title="">parent</var> is
+ an <a href=#editable>editable</a> <a href=#inline-node>inline node</a> with <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#concept-node-length title=concept-node-length>length</a> 0,
+ let <var title="">grandparent</var> be 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="">parent</var>, then
+ remove <var title="">parent</var> from <var title="">grandparent</var>, then set
+ <var title="">parent</var> to <var title="">grandparent</var>.
+ <!--
+ Taking insertText to test the case where strip wrappers is false, with
+ value a: <p>[foo<b>bar</b>]baz becomes <p>a[]baz per spec, in IE9, and in
+ Chrome 14 dev. Firefox 7.0a2 and Opera 11.50 make it <p>a[]<b></b>baz,
+ with a useless wrapper. <p>foo<b>[bar</b>baz] becomes <p>foo<b>a[]</b> per
+ spec and in IE9 and Firefox 7.0a2 and Opera 11.50; in Chrome 14 dev
+ apparently it initially becomes <p>fooa[], but then the style is recreated.
+ This is detectable if you do something weird like <span
+ style=color:#aBcDeF> instead of <b>: it comes <font class=Apple-style-span
+ color=#abcdef> or such. I follow IE9 in all cases, because it makes the
+ most sense.
+ -->
<li>If <var title="">parent</var> is <a href=#editable>editable</a> or an <a href=#editing-host>editing
host</a>, is not an <a href=#inline-node>inline node</a>, and 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>,
--- a/implementation.js Sun Jul 24 11:38:06 2011 -0600
+++ b/implementation.js Sun Jul 24 12:01:11 2011 -0600
@@ -4323,10 +4323,12 @@
// "Remove node from parent."
parent_.removeChild(node);
- // "If strip wrappers is true, while parent is an editable inline node
- // with length 0, let grandparent be the parent of parent, then remove
- // parent from grandparent, then set parent to grandparent."
- if (stripWrappers) {
+ // "If strip wrappers is true or parent is not an ancestor container of
+ // start node, while parent is an editable inline node with length 0,
+ // let grandparent be the parent of parent, then remove parent from
+ // grandparent, then set parent to grandparent."
+ if (stripWrappers
+ || (!isAncestor(parent_, startNode) && parent_ != startNode)) {
while (isEditable(parent_)
&& isInlineNode(parent_)
&& getNodeLength(parent_) == 0) {
--- a/source.html Sun Jul 24 11:38:06 2011 -0600
+++ b/source.html Sun Jul 24 12:01:11 2011 -0600
@@ -3874,11 +3874,24 @@
<li>Remove <var>node</var> from <var>parent</var>.
- <li>If <var>strip wrappers</var> is true, while <var>parent</var> is an
- <span>editable</span> <span>inline node</span> with [[nodelength]] 0, let
- <var>grandparent</var> be the [[parent]] of <var>parent</var>, then remove
- <var>parent</var> from <var>grandparent</var>, then set <var>parent</var>
- to <var>grandparent</var>.
+ <li>If <var>strip wrappers</var> is true or <var>parent</var> is not an
+ [[ancestorcontainer]] of <var>start node</var>, while <var>parent</var> is
+ an <span>editable</span> <span>inline node</span> with [[nodelength]] 0,
+ let <var>grandparent</var> be the [[parent]] of <var>parent</var>, then
+ remove <var>parent</var> from <var>grandparent</var>, then set
+ <var>parent</var> to <var>grandparent</var>.
+ <!--
+ Taking insertText to test the case where strip wrappers is false, with
+ value a: <p>[foo<b>bar</b>]baz becomes <p>a[]baz per spec, in IE9, and in
+ Chrome 14 dev. Firefox 7.0a2 and Opera 11.50 make it <p>a[]<b></b>baz,
+ with a useless wrapper. <p>foo<b>[bar</b>baz] becomes <p>foo<b>a[]</b> per
+ spec and in IE9 and Firefox 7.0a2 and Opera 11.50; in Chrome 14 dev
+ apparently it initially becomes <p>fooa[], but then the style is recreated.
+ This is detectable if you do something weird like <span
+ style=color:#aBcDeF> instead of <b>: it comes <font class=Apple-style-span
+ color=#abcdef> or such. I follow IE9 in all cases, because it makes the
+ most sense.
+ -->
<li>If <var>parent</var> is <span>editable</span> or an <span>editing
host</span>, is not an <span>inline node</span>, and has no [[children]],
--- a/tests.js Sun Jul 24 11:38:06 2011 -0600
+++ b/tests.js Sun Jul 24 12:01:11 2011 -0600
@@ -468,6 +468,11 @@
'<p>foo<span style=color:#aBcDeF>[bar]</span>baz',
'<p>foo<span style=color:#aBcDeF>{bar}</span>baz',
'<p>foo{<span style=color:#aBcDeF>bar</span>}baz',
+ '<p>[foo<span style=color:#aBcDeF>bar]</span>baz',
+ '<p>{foo<span style=color:#aBcDeF>bar}</span>baz',
+ '<p>foo<span style=color:#aBcDeF>[bar</span>baz]',
+ '<p>foo<span style=color:#aBcDeF>{bar</span>baz}',
+ '<p>foo<span style=color:#aBcDeF>[bar</span><span style=color:#fEdCbA>baz]</span>quz',
'foo<b>[bar]</b>baz',
'foo<b>{bar}</b>baz',
@@ -1274,6 +1279,11 @@
'<p>foo<span style=color:#aBcDeF>[bar]</span>baz',
'<p>foo<span style=color:#aBcDeF>{bar}</span>baz',
'<p>foo{<span style=color:#aBcDeF>bar</span>}baz',
+ '<p>[foo<span style=color:#aBcDeF>bar]</span>baz',
+ '<p>{foo<span style=color:#aBcDeF>bar}</span>baz',
+ '<p>foo<span style=color:#aBcDeF>[bar</span>baz]',
+ '<p>foo<span style=color:#aBcDeF>{bar</span>baz}',
+ '<p>foo<span style=color:#aBcDeF>[bar</span><span style=color:#fEdCbA>baz]</span>quz',
'foo<b>[bar]</b>baz',
'foo<b>{bar}</b>baz',
@@ -1669,6 +1679,12 @@
'foo<span style=color:#aBcDeF>[bar]</span>baz',
'foo<span style=color:#aBcDeF>{bar}</span>baz',
'foo{<span style=color:#aBcDeF>bar</span>}baz',
+ '[foo<span style=color:#aBcDeF>bar]</span>baz',
+ '{foo<span style=color:#aBcDeF>bar}</span>baz',
+ 'foo<span style=color:#aBcDeF>[bar</span>baz]',
+ 'foo<span style=color:#aBcDeF>{bar</span>baz}',
+ 'foo<span style=color:#aBcDeF>[bar</span><span style=color:#fEdCbA>baz]</span>quz',
+
['', 'foo[bar]baz'],
['\0', 'foo[bar]baz'],
['\x07', 'foo[bar]baz'],
@@ -1741,6 +1757,11 @@
'foo<span style=color:#aBcDeF>[bar]</span>baz',
'foo<span style=color:#aBcDeF>{bar}</span>baz',
'foo{<span style=color:#aBcDeF>bar</span>}baz',
+ '[foo<span style=color:#aBcDeF>bar]</span>baz',
+ '{foo<span style=color:#aBcDeF>bar}</span>baz',
+ 'foo<span style=color:#aBcDeF>[bar</span>baz]',
+ 'foo<span style=color:#aBcDeF>{bar</span>baz}',
+ 'foo<span style=color:#aBcDeF>[bar</span><span style=color:#fEdCbA>baz]</span>quz',
'foo<b>[bar]</b>baz',
'foo<b>{bar}</b>baz',
@@ -2042,6 +2063,11 @@
'<p>foo<span style=color:#aBcDeF>[bar]</span>baz',
'<p>foo<span style=color:#aBcDeF>{bar}</span>baz',
'<p>foo{<span style=color:#aBcDeF>bar</span>}baz',
+ '<p>[foo<span style=color:#aBcDeF>bar]</span>baz',
+ '<p>{foo<span style=color:#aBcDeF>bar}</span>baz',
+ '<p>foo<span style=color:#aBcDeF>[bar</span>baz]',
+ '<p>foo<span style=color:#aBcDeF>{bar</span>baz}',
+ '<p>foo<span style=color:#aBcDeF>[bar</span><span style=color:#fEdCbA>baz]</span>quz',
],
//@}
inserttext: [
@@ -2129,6 +2155,11 @@
'<p>foo<span style=color:#aBcDeF>[bar]</span>baz',
'<p>foo<span style=color:#aBcDeF>{bar}</span>baz',
'<p>foo{<span style=color:#aBcDeF>bar</span>}baz',
+ '<p>[foo<span style=color:#aBcDeF>bar]</span>baz',
+ '<p>{foo<span style=color:#aBcDeF>bar}</span>baz',
+ '<p>foo<span style=color:#aBcDeF>[bar</span>baz]',
+ '<p>foo<span style=color:#aBcDeF>{bar</span>baz}',
+ '<p>foo<span style=color:#aBcDeF>[bar</span><span style=color:#fEdCbA>baz]</span>quz',
'foo<a href=http://www.google.com/><font color=black>[bar]</font></a>baz',
],
//@}