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

[whatwg] Specification of window.find()

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 15 Feb 2012 19:26:21 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.1202151859080.11170@ps20323.dreamhostps.com>
On Wed, 20 Jul 2011, Tim Down wrote:
> On 6 January 2011 21:53, Ian Hickson <ian at hixie.ch> wrote:
> > On Wed, 27 Oct 2010, benjamin.poulain at nokia.com wrote:
> >>
> >> I would like to suggest a change for the main HTML 5 specification:
> >> http://www.whatwg.org/specs/web-apps/current-work/
> >>
> >> The problem I have is with the Window object specification
> >> (http://www.whatwg.org/specs/web-apps/current-work/#the-window-object ).
> >> It does not mention the method find() which can be found on most engines
> >> (e.g.: https://developer.mozilla.org/en/DOM/window.find ).
> >
> > It looks like IE doesn't implement this, so it's probably not strictly
> > required for compat with the Web.
> >
> > What are the use cases for this feature?
> 
> It's useful for custom search features. I've recommended it a few
> times on Stack Overflow for people wanting to highlight or somehow
> style all occurrences of a piece of text that may span nodes (it's
> this part that is the compelling feature). You can achieve the same
> using TextRange in IE. For example:
> 
> http://stackoverflow.com/questions/5886858/full-text-search-in-html-ignoring-tags
> 
> I think this is a valid use case. On a related note, I would like to
> see equivalents of some of the text-based methods in IE's TextRange
> make their way into Range, but that's a separate issue.

So really it's not for use as a UI feature, but as a way to get Range 
objects for modifying the DOM. Interesting.


On Wed, 20 Jul 2011, Aryeh Gregor wrote:
> 
> However, the implementation here doesn't do what you'd want: it selects 
> the text, destroying any existing selection.  You can work around it by 
> preserving and then restoring the selection somehow, but it's not ideal 
> at all.  It would make much more sense to have a function that returned 
> a Range or list of Ranges.

So I guess we have to make a decision for the platform here.

Do we want:

 - To spec window.find() in all its historical glory, and have it 
   implemented everywhere?

 - To spec a subset of window.find() that just does the use case described 
   above, namely to destructively change the selection to a matching part 
   of the DOM so that it can be manipulated by script?

 - To spec a new API that just returns matching ranges and then allows 
   those ranges to be manipulated like the selection can be today?

 - To encourage authors to write a library that does this for them, and
   not bother to provide a dedicated API at all?

Which would implementations that don't do the full window.find() today be 
willing to do?

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 15 February 2012 11:26:21 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:39 UTC