]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: loose children property in normalized records
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 25 Jul 2025 12:36:11 +0000 (14:36 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 25 Jul 2025 12:36:11 +0000 (14:36 +0200)
packages/router/src/experimental/router.ts
packages/router/src/navigationGuards.ts

index 2f9cb34216d2fda0d0f2962004b4ce330a4086a3..2a7c7606e24bd8ea61dbc6d0eed582b8f1af520c 100644 (file)
@@ -328,14 +328,21 @@ export type EXPERIMENTAL_RouteRecordNormalized =
   | EXPERIMENTAL_RouteRecordNormalized_Matchable
   | EXPERIMENTAL_RouteRecordNormalized_Group
 
+export function normalizeRouteRecord(
+  record: EXPERIMENTAL_RouteRecord_Group
+): EXPERIMENTAL_RouteRecordNormalized_Group
 export function normalizeRouteRecord(
   record: EXPERIMENTAL_RouteRecord_Matchable
-): EXPERIMENTAL_RouteRecordNormalized_Matchable {
+): EXPERIMENTAL_RouteRecordNormalized_Matchable
+export function normalizeRouteRecord(
+  record: EXPERIMENTAL_RouteRecord_Matchable | EXPERIMENTAL_RouteRecord_Group
+):
+  | EXPERIMENTAL_RouteRecordNormalized_Matchable
+  | EXPERIMENTAL_RouteRecordNormalized_Group {
   // we can't define mods if we want to call defineProperty later
-  const normalizedRecord: Omit<
-    EXPERIMENTAL_RouteRecordNormalized_Matchable,
-    'mods'
-  > = {
+  const normalizedRecord:
+    | Omit<EXPERIMENTAL_RouteRecordNormalized_Matchable, 'mods'>
+    | Omit<EXPERIMENTAL_RouteRecordNormalized_Group, 'mods'> = {
     meta: {},
     // must be defined as non enumerable because it contains modules
     // mods: {},
@@ -354,7 +361,9 @@ export function normalizeRouteRecord(
     value: {},
   })
 
-  return normalizedRecord as EXPERIMENTAL_RouteRecordNormalized_Matchable
+  return normalizedRecord as
+    | EXPERIMENTAL_RouteRecordNormalized_Matchable
+    | EXPERIMENTAL_RouteRecordNormalized_Group
 }
 
 // TODO: probably need some generic types
@@ -671,9 +680,9 @@ export function experimental_createRouter(
     // }
 
     const matchedRoute = resolver.resolve(
-      // incompatible types
+      // FIXME: incompatible types
       rawLocation as any,
-      // incompatible `matched` requires casting
+      // FIXME: incompatible `matched` requires casting
       currentLocation as any
     )
     const href = routerHistory.createHref(matchedRoute.fullPath)
@@ -779,7 +788,8 @@ export function experimental_createRouter(
     const from = currentRoute.value
     const data: HistoryState | undefined = (to as RouteLocationOptions).state
     const force: boolean | undefined = (to as RouteLocationOptions).force
-    const replace = (to as RouteLocationOptions).replace ?? _replace
+    const replace = targetLocation.replace ?? _replace
+    console.log({ replace })
 
     const shouldRedirect = handleRedirectRecord(targetLocation)
 
index 4904788ac9bff169b6a66eac00141a361bf475eb..a2be525a573977df0819167272f3d014a08ceffd 100644 (file)
@@ -241,7 +241,13 @@ export function extractComponentsGuards(
   const guards: Array<() => Promise<void>> = []
 
   for (const record of matched) {
-    if (__DEV__ && !record.components && !record.children.length) {
+    if (
+      __DEV__ &&
+      !record.components &&
+      // in the nex records, there is no children, only parents
+      record.children &&
+      !record.children.length
+    ) {
       warn(
         `Record with path "${record.path}" is either missing a "component(s)"` +
           ` or "children" property.`