[whatwg] Control over selection direction

Marijn Haverbeke marijnh at gmail.com
Thu Jan 13 10:54:38 PST 2011


> Would you use it in cases other than restoring previous selection?

My typical use case is that I mess with the content of the input, and
then restore the selection. For example, after adding three characters
to the front, I then restore selectionStart and selectionEnd by adding
three to their original values. It seems that simply saving and
restoring a selection does not address this case.

(On top of that, I'd argue that my proposal is more 'basic', giving
programmers direct control over the DOM, rather than a convenient
interface that breaks down for corner cases. See Microsoft's original
selection API for an interesting example of a convenient API like
that.)



More information about the whatwg mailing list