WICG / scroll-to-text-fragment

Proposal to allow specifying a text snippet in a URL fragment
Other
586 stars 43 forks source link

Improve integration with navigation #225

Closed bokand closed 1 year ago

bokand commented 1 year ago

This PR makes it so that the fragment directive is stripped from the URL whenever it is set to a history entry. Instead, the history entry keeps it in a separate directive state.

The directive state is shared between contiguous history entries where the only difference is the non-directive portion of the fragment.

Moving between session history entries will cause the directive state, if it differs from the current entry, to be set into an uninvoked directives member on the Document. The "scroll to the fragment" steps will read directives from this member and attempt to perform the text search.

When the fragment search ends, uninvoked directives is always cleared.

The changes here are primarily in the "3.3 The Fragment Directive" and "3.4 Text Directives" sections. Most changes in other sections are minor and/or text that was moved out into these two section (and heavily rewritten).

Fixes #217


Preview | Diff

bokand commented 1 year ago

@jakearchibald @annevk, how does this look?

bokand commented 1 year ago

@jakearchibald - latest commits should have addressed all your comments, WDYT?

bokand commented 1 year ago

@annevk - in the interest of rationing your attention I'll merge this based on Jake's review (and the fact it'll be reviewed again on merge to HTML). But feel free to lmk if you'd prefer I wait on your review in future PRs (also happy to fix any issues post-merge)

annevk commented 1 year ago

Thanks, that's fine. General approach seems good to me.