[whatwg] More HTML Editing Commands questions

Tim Down timdown at gmail.com
Thu May 19 16:33:06 PDT 2011


On 19 May 2011 21:10, Aryeh Gregor <Simetrical+w3c at gmail.com> wrote:
> (You know that
>
> <!DOCTYPE HTML>
> <style>
>    span { border: solid black 1px; }
> </style>
> <p><span>One</span></p><span>
> </span><p><span>Two</span></p>
>
> will behave the same as what you wrote and is just as conformant, right?)

Actually I didn't. Thanks for the tip. I have some HTML5 reading to do.

>> What I have in mind doesn't involve DOM mutation. Imagine the
>> selection is collapsed in the middle of a text node and the bold
>> command is called. The browser now has an internal flag set but there
>> is no change in the DOM. However, if the selection is moved away from
>> its current position, that flag is unset and that position is no
>> longer notionally bold, even if the selection is then returned to its
>> original position before anything else happens. This happens in all
>> browsers. To achieve this with JavaScript running in the page, you
>> need a reliable selection change event. For the purposes of simply
>> tracking the user moving the selection, an asynchronous event would be
>> fine.
>
> Assuming that your goal here is to replicate execCommand() from
> JavaScript, what happens if the user puts the selection somewhere,
> bolds, types something, then moves the selection elsewhere?  I guess
> that works fine if there are reliable input events (are there?), and
> they're ordered properly with respect to the selection change events.

There's no issue in that scenario if there is a selection change event
that fires when the the user does the final selection move. What are
you getting at? Sorry if I'm missing something.

Tim



More information about the whatwg mailing list