Skip to content
This repository was archived by the owner on Aug 21, 2026. It is now read-only.
This repository was archived by the owner on Aug 21, 2026. It is now read-only.

Should event.destination contain useful id/key/index for non-"traverse" navigations? #138

Closed

Description

@domenic

Spinning off from #97, re-summarizing based on the current state of things.

Currently event.destination in the navigate event contains:

  • url, sameDocument, and getState(), always
  • key and id, which are the relevant value for "traverse" navigations but null for "push"/"replace"/"reload" navigations
  • index, which is the relevant value for "traverse" navigations but -1 for "push"/"replace"/"reload" navigations

Should we change either of these last two bullets? Some ideas:

  • index is always easy: it's either navigation.currentEntry.index for replace/reload, or navigation.currentEntry.index + 1 for push.
  • key is easy for replace/reload: it's always navigation.currentEntry.key.
  • Beyond that, key and id are a bit trickier to implement and spec as we'd essentially have to generate them up front and thread them through, instead of generating them once the navigation finishes and we update the entries list. It's still probably doable though, if there's a use case.

I'm reasonably happy with having these be null/-1 for now, but I'd like to have this issue to track if people have any use cases for key/id/index on non-"traverse" navigations.

Activity

  1. added
    additionA proposed addition which could be added later without impacting the rest of the API
    on Jul 28, 2021
  2. added this to the Might block v1 milestone on Nov 4, 2021
  3. domenic commented on Mar 17, 2022

    @domenic
    CollaboratorAuthor

    @annevk, @smaug----, @natechapin and I met offline and were unable to think of any compelling use cases for this. In addition @natechapin confirmed that the plumbing work would be quite a lift to implement, at least in Chromium.

    We'll consider this settled in favor of the status quo. (Which is tested a good amount in web platform tests already.)

    This isn't impossible to change after initial implementations, so if someone discovers a really key use case please let us know. (Any compat issues would come about if people start using these null/-1 values as signifiers of non-traverse navigations, instead of using navigationType !== "traverse". Which seems like something people would do, eventually, but probably wouldn't do in the early days of this API's existence.)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    additionA proposed addition which could be added later without impacting the rest of the APIfeedback wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions