Skip to content

Calling history.pushState to a different URL triggers a full page navigation #48

@KonnorRogers

Description

@KonnorRogers

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure it has not already been reported

Version (i.e. v2.x.x)

1.0.1-alpha.212

Node.js version (i.e. 18.x, or N/A)

N/A

Operating system

None

Operating system version (i.e. 20.04, 11.3, 10, or N/A)

No response

Description

When calling window.history.pushState({}, "", "http://localhost/new-url") it forces a page navigation.

This feels unexpected as it only happens in FF / Safari. In Chrome, this does not happen, assuming because the polyfill never applies because the polyfill is natively supported.

Steps to Reproduce

import "https://cdn.jsdelivr.net/npm/@virtualstate/navigation@1.0.1-alpha.212/esnext/polyfill.js/+esm"


history.pushState({}, "", "http://localhost:9000/new-url")

And the browser will try to do a new page navigation.

Expected Behavior

the browser should only update the URL in the history. It should not attempt to navigate.

Is there a way to opt-out of this behavior? As it is, I found it interesting in Chrome URLs automatically updated, but with the polyfill I have to call pushState() after calling my navigation handler, unlike in Chrome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions