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

Issue with hashChange determination for NavigateEvent when dispatched through replaceState/pushState #10389

Closed
rwlbuis opened this issue Jun 4, 2024 · 3 comments · Fixed by #10393

Comments

@rwlbuis
Copy link

rwlbuis commented Jun 4, 2024

What is the issue with the HTML Standard?

When looking at for example navigate-event/navigate-history-pushState.html, the test expectation for hashChange is false. However from looking at the specification it should be true. It seems when using History API the determination is different, yet this does not seem reflected in the specification AFAICS.

@domenic
Copy link
Member

domenic commented Jun 4, 2024

My instinct here is that the test and Chromium's implementation is wrong, and we should update them. I cannot find any evidence of this being intentional.

@rwlbuis
Copy link
Author

rwlbuis commented Jun 4, 2024

My instinct here is that the test and Chromium's implementation is wrong, and we should update them. I cannot find any evidence of this being intentional.

That plan would align well with WebKit's current implementation.

@domenic
Copy link
Member

domenic commented Jun 5, 2024

I started working on this and then I had second thoughts. I think this might have been intentional after all.

The original explainer states:

hashChange: a boolean, indicating whether or not this is a same-document fragment navigation.

Additionally, a large amount of example code does stuff like

navigation.addEventListener("navigate", e => {
  if (e.hashChange) {
    // Assume this is the user clicking on a fragment link and ignore it.
    return;
  }

  // Otherwise, process this with navigation interception.
});

I think changing how such code reacts to history.pushState("/#fragment") might cause compat problems. Worse, I think it might make it harder for people to write nice apps that use the navigation API.

So now I am thinking we should update the spec to match Chromium's behavior and the tests... I am open to being persuaded otherwise, especially by web developers with experience using the navigation API. But I'll tentatively proceed with a spec patch.

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

Successfully merging a pull request may close this issue.

3 participants