Skip to content

data-sveltekit-replacestate does not work for #hash links #9546

@edde746

Description

@edde746

Describe the bug

When clicking on a hash link that has the data-sveltekit-replacestate attribute, the expected behavior is to update the URL without pushing a new history entry. However, the bug causes the history object to be pushed even when the data-sveltekit-replacestate attribute is used, resulting in unexpected navigation history behavior.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-jsaxq9

Steps to reproduce the behavior:

  1. Create a new SvelteKit project or open an existing one
  2. Add a hash link with the data-sveltekit-replacestate attribute, like the following: <a data-sveltekit-replacestate href="#c">c</a>
  3. Start the development server and navigate to the page containing the hash link
  4. Click on the link with the attribute
  5. Observe the URL change and the browser's navigation history

Logs

No response

System Info

Not applicable

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions