- From: Tim Down <timdown@gmail.com>
- Date: Wed, 20 Jul 2011 23:23:24 +0100
On 20 July 2011 17:58, Aryeh Gregor <Simetrical+w3c at gmail.com> wrote: > 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. Yes, but it's significantly better than the alternative, which is to write your own code to search for text that spans nodes. > It would make much more sense to have a > function that returned a Range or list of Ranges. Absolutely. > 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 . . . Agreed. My number two feature (well, it would make the top 5, at least) would be removing the restriction on execCommand() only working on editable content. This very use case shows that its usefulness extends beyond editable content. The temporarily-switch-designMode-on workaround is ugly, and destroys the selection in some browsers. Tim
Received on Wednesday, 20 July 2011 15:23:24 UTC