Skip to content

Commit 04352df

Browse files
committed
chore: check guards parameters call to fix current browser tests
1 parent 1b99c9b commit 04352df

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

packages/router/src/navigationGuards.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,27 @@ export function guardToPromiseFn(
169169
}
170170

171171
// wrapping with Promise.resolve allows it to work with both async and sync guards
172-
const guardReturn = runWithContext(() =>
173-
guard.call(
174-
record && record.instances[name!],
175-
to,
176-
from,
177-
__DEV__ ? canOnlyBeCalledOnce(next, to, from, info) : next,
178-
info
179-
)
180-
)
172+
const guardReturn =
173+
guard.length > 3
174+
? runWithContext(() =>
175+
guard.call(
176+
record && record.instances[name!],
177+
to,
178+
from,
179+
__DEV__ ? canOnlyBeCalledOnce(next, to, from, info) : next,
180+
info
181+
)
182+
)
183+
: runWithContext(() =>
184+
guard.call(
185+
record && record.instances[name!],
186+
to,
187+
from,
188+
__DEV__ ? canOnlyBeCalledOnce(next, to, from) : next,
189+
info
190+
)
191+
)
192+
181193
let guardCall = Promise.resolve(guardReturn)
182194

183195
if (guard.length < 3) guardCall = guardCall.then(next)

0 commit comments

Comments
 (0)