W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2012

[whatwg] Request for new DOM property textarea.selectionText

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Mon, 30 Apr 2012 23:17:49 -0700
Message-ID: <CABNRm603hhD_HBerHRxGzb+2VbHOzfPg6edGetsjqT151d5swQ@mail.gmail.com>
On Mon, Apr 30, 2012 at 11:01 PM, Ian Hickson <ian at hixie.ch> wrote:

> On Mon, 30 Apr 2012, Ojan Vafai wrote:
> > I'd also like to see us expose a method for getting the text that
> > accepts optional start/end arguments. Mainly, this allows for the
> > possibility of browser vendors to performance optimize (e.g. don't need
> > to convert the whole string to a JS string just to get the 5 selected
> > characters out).
>
> Is that really that expensive? Seems like it'd be better just to have UAs
> optimise their JS string implementations so that it can just be backed by
> the same thing as the DOM or the control's editor. (I believe Mozilla may
> in fact already do that.)
>

In theory, this is possible. But any sort of proxy, etc... that lazily
obtain the value (e.g. delaying it until substr, etc... is called) is hard
to implement in practice because we need to serialize text before DOM is
modified. e.g.

1 var inputValue = input.value;
2 var textUsed = input.value.substr(5, 10);

In the above example, inputValue could be a proxy object. However, in the
example below:

1 var inputValue = input.value;
2 input.value = 'bar';
3 var textUsed = input.value.substr(5, 10);

we need to serialize the string immediately before the statement in the
line 2 is evaluated.

- Ryosuke
Received on Monday, 30 April 2012 23:17:49 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:07 GMT