Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatic API #261

Open
brillout opened this issue Jan 28, 2025 · 1 comment
Open

Programmatic API #261

brillout opened this issue Jan 28, 2025 · 1 comment

Comments

@brillout
Copy link

As the author of a React/Vue framework (Vike) I need to be able to programmatically invoke the browser's native behavior upon a text fragment #:~:text=, for example:

window.scrollTo('#:~:text=someText')

A workaround is location.hash = '#:~:text=someText' but it's error prone (e.g. leads to infinite loops when done in a popstate event) and pollutes the browser history.

Is that on the radar?

Related: vikejs/vike#2114.

@bokand
Copy link
Collaborator

bokand commented Feb 3, 2025

I did a bunch of work on the spec in #225 that I hope makes this at least better defined. The example here is probably the easiest to parse. Per spec, I think the most straightforward would be to use replaceState if you don't want it to change history state.

That said, this doesn't currently work (in Chrome at least, haven't tried in other browsers) since I wasn't able to change Chrome's implementation to match the improved spec. Unfortunately I'm not working in this area anymore so am unable to do so in the foreseeable future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants