[whatwg] Specification of window.find()

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 . . .

Received on Wednesday, 20 July 2011 09:58:47 UTC