This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Consider the following test case for bold: <p>[foo</p><p> <span>bar</span> </p><p>baz]</p> We wrap each of the inline nodes one by one: 1) <p>[foo</p><p> <span>bar</span> </p><p>baz]</p> 2) <p>[<b>foo</b></p><p> <span>bar</span> </p><p>baz]</p> 3) <p>[<b>foo</b></p><p> <b><span>bar</span></b> </p><p>baz]</p> 4) <p>[<b>foo</b></p><p> <b><span>bar</span> </b></p><p>baz]</p> 5) <p>[<b>foo</b></p><p> <b><span>bar</span> </b></p><p><b>baz</b>]</p> Notice how when going from 2->3, we skip the space before <span>bar</span>. That's because it's an invisible node, so we don't want to create a <b> to wrap it in (bug 13996). This is to avoid wrapping standalone spaces like in <p>[foo</p> <p>bar]</p> But the second space we do wrap, because we'll add invisible nodes to existing adjacent wrappers just fine. This is needed for cases like <span>[foo</span> <span>bar]</span> where we want <b><span>[foo</span> <span>bar]</span></b> rather than <b><span>[foo</span></b> <b><span>bar]</span></b> The only way I see to fix this is to rewrite "setting the selection's value" to look at whole runs of adjacent nodes before deciding which ones to force. Then we can force a whole run if it contains any visible editable node, whether there are invisible nodes before or after.
It turns out there was a simpler way to fix the problem: https://dvcs.w3.org/hg/editing/rev/ee2791b98b92 Essentially, we just refuse to wrap invisible nodes by themselves. But when merging into an adjacent sibling, we skip over any intervening invisible nodes, and if we decide to merge, we bring the invisible nodes along too. So the test case now becomes 1) <p>[foo</p><p> <span>bar</span> </p><p>baz]</p> 2) <p>[<b>foo</b></p><p> <span>bar</span> </p><p>baz]</p> 3) <p>[<b>foo</b></p><p> <b><span>bar</span></b> </p><p>baz]</p> The last space doesn't get wrapped, because it's invisible. By contrast: 1) <span>[foo</span><!--bar--><span>baz]</span> 2) <b><span>[foo</span></b><!--bar--><span>baz]</span> 2) <b><span>[foo</span><!--bar--><span>baz]</span></b> The invisible node isn't wrapped by itself, but when we want to wrap the final "baz", we stick it into the existing <b> along with the intervening invisible node.