Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/vue-router/src/viewStacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,15 @@ export const createViewStacks = (router: Router) => {
if (!viewStack) return;

const startIndex = viewStack.findIndex((v) => v === viewItem);
if (startIndex === -1) return;

for (let i = startIndex + 1; i < startIndex - delta; i++) {
// delta from popstate reflects browser history depth, which can exceed
// the outlet's view stack when tab switches build up history without
// adding new view items. Clamp to the stack length so we never index
// past the end of the array.
const endIndex = Math.min(viewStack.length, startIndex - delta);

for (let i = startIndex + 1; i < endIndex; i++) {
const viewItem = viewStack[i];
viewItem.mount = false;
viewItem.ionPageElement = undefined;
Expand Down Expand Up @@ -233,8 +240,11 @@ export const createViewStacks = (router: Router) => {
if (!viewStack) return;

const startIndex = viewStack.findIndex((v) => v === viewItem);
if (startIndex === -1) return;

const endIndex = Math.min(viewStack.length, startIndex + delta);

for (let i = startIndex + 1; i < startIndex + delta; i++) {
for (let i = startIndex + 1; i < endIndex; i++) {
viewStack[i].mount = true;
}
};
Expand Down
Loading