WICG / scroll-to-text-fragment

Proposal to allow specifying a text snippet in a URL fragment
Other
589 stars 42 forks source link

Update the algorithm for finding rangeEnd #176

Closed bokand closed 2 years ago

bokand commented 2 years ago

Fixes a bug in the algorithm where an unmatched rangeEnd+suffx will continue the search by starting to look for the next prefix. However, if we didn't find the correct rangeEnd+suffix pair, we should continue to look until the end of the document because there may be another one. For example:

matchStart foo matchEnd bar matchEnd baz

If the directive is text=matchStart,matchEnd,-baz, the current algorithm will find the first instance of matchEnd, realize the suffix doesn't match and iterate the loop which will continue the search from the beginning, starting from foo.

This PR changes the algorithm to continue searching for a matching rangeEnd+suffix until the end of the document.


Preview | Diff