File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -1004,6 +1004,44 @@ describe('RouterMatcher.resolve', () => {
1004
1004
)
1005
1005
) . toMatchSnapshot ( )
1006
1006
} )
1007
+
1008
+ it ( 'avoids records with children without a component nor name' , ( ) => {
1009
+ assertErrorMatch (
1010
+ {
1011
+ path : '/articles' ,
1012
+ children : [ { path : ':id' , components } ] ,
1013
+ } ,
1014
+ { path : '/articles' }
1015
+ )
1016
+ } )
1017
+
1018
+ it ( 'avoids nested records with children without a component nor name' , ( ) => {
1019
+ assertErrorMatch (
1020
+ {
1021
+ path : '/app' ,
1022
+ components,
1023
+ children : [
1024
+ {
1025
+ path : '/articles' ,
1026
+ children : [ { path : ':id' , components } ] ,
1027
+ } ,
1028
+ ] ,
1029
+ } ,
1030
+ { path : '/articles' }
1031
+ )
1032
+ } )
1033
+
1034
+ it ( 'can reach a named route with children and no component if named' , ( ) => {
1035
+ assertRecordMatch (
1036
+ {
1037
+ path : '/articles' ,
1038
+ name : 'ArticlesParent' ,
1039
+ children : [ { path : ':id' , components } ] ,
1040
+ } ,
1041
+ { name : 'ArticlesParent' } ,
1042
+ { name : 'ArticlesParent' , path : '/articles' }
1043
+ )
1044
+ } )
1007
1045
} )
1008
1046
1009
1047
describe ( 'children' , ( ) => {
Original file line number Diff line number Diff line change @@ -178,7 +178,16 @@ export function createRouterMatcher(
178
178
// parent.children.push(originalRecord)
179
179
// }
180
180
181
- insertMatcher ( matcher )
181
+ // Avoid adding a record that doesn't display anything. This allows passing through records without a component to
182
+ // not be reached and pass through the catch all route
183
+ if (
184
+ ( matcher . record . components &&
185
+ Object . keys ( matcher . record . components ) . length ) ||
186
+ matcher . record . name ||
187
+ matcher . record . redirect
188
+ ) {
189
+ insertMatcher ( matcher )
190
+ }
182
191
}
183
192
184
193
return originalMatcher
You can’t perform that action at this time.
0 commit comments