[whatwg] Specification of window.find()

Aryeh Gregor Simetrical+w3c at gmail.com
Wed Jul 20 09:58:47 PDT 2011

On Wed, Jul 20, 2011 at 6:14 AM, Tim Down <timdown at gmail.com> wrote:
> 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.

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.

Of course, for the use-case you posted, execCommand() would also have
to work on Ranges instead of just the selection, but that should
probably be feature #1 to add to it anyway . . .

More information about the whatwg mailing list