Skip to content

History entries as a list or a tree #20

Closed
@Yay295

Description

@Yay295

Currently history entries act as a list. As you push more entries the list gets longer, and if you go back to a previous entry and make another push it overwrites all of the previous future entries. I think this makes sense, and it's how a lot of other things work on computers as well (ex. undo/redo when typing a document). However with this new API each entry has a unique key, and as @domenic mentions in #7, this could lead to problems if you try to navigate to an entry that has been overwritten:

const uniqueKey = appHistory.currentEntry.key;
appHistory.replaceCurrentEntry();
appHistory.navigateTo(uniqueKey);

However, if history entries were treated as a tree rather than a list, the above code would not cause issues. There is even some allowance for this in the existing History API: https://html.spec.whatwg.org/multipage/history.html#history-notes

The History interface is not meant to place restrictions on how implementations represent the session history to the user.

For example, session history could be implemented in a tree-like manner, with each page having multiple "forward" pages. This specification doesn't define how the linear list of pages in the history object are derived from the actual session history as seen from the user's perspective.

With the existing History API there is no way to actually navigate a tree, but with this new API there is.

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