jonaskuske / smoothscroll-anchor-polyfill

⚓ Apply smooth scroll to anchor links, polyfill scroll-behavior
https://jonaskuske.github.io/smoothscroll-anchor-polyfill
MIT License
41 stars 3 forks source link

:target pseudo-class is not toggled #20

Open jonaskuske opened 5 years ago

jonaskuske commented 5 years ago

When the polyfill updates the URL through pushState(), CSS pseudo-classes like :target are not updated accordingly. This is actually a browser bug as the spec is very clear about this, but we can maybe still work around it by setting location.hash after the scroll is completed (so it doesn't interrupt the smoothscroll), similar to pendingFocusChange – shouldn't be visible at all, as the hash was updated by history.pushState before already, but hopefully it force-updates :target CSS classes etc.