W3C home > Mailing lists > Public > www-style@w3.org > May 2011

Re: [CSSOM] CaretPosition

From: Ojan Vafai <ojan@chromium.org>
Date: Fri, 6 May 2011 14:31:57 -0700
Message-ID: <BANLkTikUrMBtOuduzSy67O3KdZqNvG10vQ@mail.gmail.com>
To: Ms2ger <ms2ger@gmail.com>
Cc: "Olli@pettay.fi" <Olli@pettay.fi>, "www-style@w3.org" <www-style@w3.org>
On Fri, May 6, 2011 at 2:24 PM, Ms2ger <ms2ger@gmail.com> wrote:

> On 05/06/2011 09:45 PM, Ojan Vafai wrote:
>
>> I agree. It would be great if the next iteration of DOM Ranges could spec
>> Ranges as having a startPosition/endPosition that were CaretPositions.
>> This
>> is how WebKit's implementation works under the hood and it's much better
>> than dealing with node/offset pairs all the time.
>>
>
> I'm very reluctant to add new features that just duplicate existing
> functionality. Is range.startPosition.offsetNode really so much better than
> range.startContainer to make it worth the specification, implementation, and
> testing time that would need to be spent on it?
>
> This might have been a good idea when ranges were first implemented, but I
> don't see a use case that would warrant adding it now.


I'd like to add methods to CaretPosition that let you operate on each end of
the selection, e.g. a way to move up/down the DOM in visibly equivalent
positions (e.g. with <span><span><span>[POSITION]foo</span></span><span>
being able to move the position up/down is a fairly frequent need). You can
certainly write code that does this now in JS, but it ends up being bulky
and error-prone.

In either case, that's a whole separate discussion. Olli's proposal makes
sense in the absence of other future-looking ideas.

Ojan
Received on Friday, 6 May 2011 21:32:41 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:40 GMT