Skip to content

Commit

Permalink
Merge branch 'main' into feat-value-over-get-set
Browse files Browse the repository at this point in the history
  • Loading branch information
smalluban committed May 14, 2024
2 parents b695020 + d0182d2 commit e9d4d51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function setupView(hybrids, routerOptions, parent, nestedParent) {
return params;
},
(host, params, lastParams) => {
if (!lastParams) return;
if (!lastParams || !globalThis.history.state) return;

const state = globalThis.history.state;
const index = state.findIndex((entry) => {
Expand Down
11 changes: 11 additions & 0 deletions test/spec/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,17 @@ describe("router:", () => {
});
});

it("does not throw when browser pushes null state", () => {
window.history.pushState(null, "", "");
const rootView = host.views[0];
rootView.globalB = "value";

return resolveTimeout(() => {
expect(hybrids(host.views[0])).toBe(RootView);
expect(hybrids(host.children[0])).toBe(RootView);
});
});

it("displays root view", () =>
resolveTimeout(() => {
expect(hybrids(host.views[0])).toBe(RootView);
Expand Down

0 comments on commit e9d4d51

Please sign in to comment.