[whatwg] Request for new DOM property textarea.selectionText

Ian Hickson ian at hixie.ch
Mon Apr 30 23:26:40 PDT 2012


On Mon, 30 Apr 2012, Ryosuke Niwa wrote:
> >
> > 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.

That's just copy-on-write. It's hardly rocket science. :-P

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list