Skip to content

Commit f03cc5a

Browse files
committed
Fix findLastLocation so that deltas less than -1 are still relative to the specified route
1 parent 4141703 commit f03cc5a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/vue-router/src/locationHistory.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,14 @@ export const createLocationHistory = () => {
239239
}
240240
}
241241
}
242-
if (delta < -1) {
243-
return locationHistory[locationHistory.length - 1 + delta];
244-
} else {
245-
for (let i = locationHistory.length - 2; i >= 0; i--) {
246-
const ri = locationHistory[i];
247-
if (ri) {
248-
if (ri.pathname === routeInfo.pushedByRoute) {
242+
for (let i = locationHistory.length - 2; i >= 0; i--) {
243+
const ri = locationHistory[i];
244+
if (ri) {
245+
if (ri.pathname === routeInfo.pushedByRoute) {
246+
if (delta >= -1) {
249247
return ri;
250248
}
249+
return locationHistory[i + 1 + delta]
251250
}
252251
}
253252
}

0 commit comments

Comments
 (0)