Skip to content

Commit 53d063d

Browse files
bundlesize optimization
1 parent 2f70921 commit 53d063d

2 files changed

Lines changed: 90 additions & 131 deletions

File tree

‎packages/router-core/src/router.ts‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -887,22 +887,10 @@ export function getLocationChangeInfo(
887887
return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged }
888888
}
889889

890-
const locationHistoryActions = new WeakMap<ParsedLocation, HistoryAction>()
891-
892-
export function getLocationHistoryAction(location: ParsedLocation) {
893-
return locationHistoryActions.get(location)
894-
}
895-
896-
function setLocationHistoryAction(
897-
location: ParsedLocation,
898-
action: HistoryAction | undefined,
899-
) {
900-
if (action) {
901-
locationHistoryActions.set(location, action)
902-
} else {
903-
locationHistoryActions.delete(location)
904-
}
905-
}
890+
export const locationHistoryActions = new WeakMap<
891+
ParsedLocation,
892+
HistoryAction
893+
>()
906894

907895
export type CreateRouterFn = <
908896
TRouteTree extends AnyRoute,
@@ -2446,7 +2434,11 @@ export class RouterCore<
24462434
this.startTransition(async () => {
24472435
try {
24482436
this.beforeLoad()
2449-
setLocationHistoryAction(this.latestLocation, historyAction)
2437+
if (historyAction) {
2438+
locationHistoryActions.set(this.latestLocation, historyAction)
2439+
} else {
2440+
locationHistoryActions.delete(this.latestLocation)
2441+
}
24502442
const next = this.latestLocation
24512443
const prevLocation = this.stores.resolvedLocation.get()
24522444
const locationChangeInfo = getLocationChangeInfo(next, prevLocation)

0 commit comments

Comments
 (0)