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

Handle links with anchors that start with a number #603

Closed
brunosedler opened this issue Apr 5, 2024 · 1 comment
Closed

Handle links with anchors that start with a number #603

brunosedler opened this issue Apr 5, 2024 · 1 comment

Comments

@brunosedler
Copy link

Bug description

Browser "back" does not work after following a link with unpoly that contains an anchor starting with a number

Reproduction project

https://zesty-bubbly-samba.glitch.me

Steps to reproduce the behavior:

  1. Go to reproduction project linked above
  2. Click on 'Link to other page'
  3. Try to return to previous page by clicking on the browser's back button
  4. See Error: you are still on the same page but the navigation bar has been updated to the previous page

Expected behavior

Clicking on the browser's back button brings me back to the previous page.

Additional context

I did some research and found out, that in HTML 4 ids must start with a letter. See this stackoverflow answer and therefore querySelectorAll throws an exception if it comes across an Id that doesn't.

@adam12
Copy link
Member

adam12 commented Apr 5, 2024

Thanks for providing the reproduction. I can confirm I see the same.

It will be interesting to see what Henning thinks about this one. On one hand, I think we could easily regex match the selector and if it's /^#\d/, use [id="the-id"] as the selector instead.

On the other hand, MDN says that using an ID starting with an Integer can cause weirdness in other places, and should be avoided.

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