-
Notifications
You must be signed in to change notification settings - Fork 11
fix(): support route children #4816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1296,7 +1296,7 @@ function getEmptyRenderOutput(): RenderOutput { | |
| } | ||
|
|
||
| export function childrenToSlots( | ||
| children: BrickConf[] | undefined, | ||
| children: (BrickConf | RouteConf)[] | undefined, | ||
| originalSlots: SlotsConf | undefined | ||
| ) { | ||
| let newSlots = originalSlots; | ||
|
|
@@ -1317,13 +1317,21 @@ export function childrenToSlots( | |
| newSlots = {}; | ||
| for (const { slot: sl, ...child } of children) { | ||
| const slot = sl ?? ""; | ||
| if (!hasOwnProperty(newSlots, slot)) { | ||
| const type = isRouteConf(child) ? "routes" : "bricks"; | ||
| if (hasOwnProperty(newSlots, slot)) { | ||
| const slotConf = newSlots[slot]; | ||
| if (slotConf.type !== type) { | ||
| throw new Error(`Slot "${slot}" conflict between bricks and routes.`); | ||
| } | ||
| (slotConf as SlotConfOfBricks)[type as "bricks"].push( | ||
| child as BrickConf | ||
| ); | ||
|
Comment on lines
+1326
to
+1328
|
||
| } else { | ||
| newSlots[slot] = { | ||
| type: "bricks", | ||
| bricks: [], | ||
| type: type as "bricks", | ||
| [type as "bricks"]: [child as BrickConf], | ||
weareoutman marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
1330
to
+1332
|
||
| }; | ||
| } | ||
| (newSlots[slot] as SlotConfOfBricks).bricks.push(child); | ||
| } | ||
| } | ||
| return newSlots; | ||
|
|
@@ -1357,3 +1365,7 @@ function isRouteParamsEqual( | |
| const d = omitBy(b, omitNumericKeys); | ||
| return isEqual(c, d); | ||
| } | ||
|
|
||
| function isRouteConf(child: BrickConf | RouteConf): child is RouteConf { | ||
| return !!(child as RouteConf).path && !(child as BrickConf).brick; | ||
weareoutman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,7 +26,7 @@ function replaceInBrick(brick: BrickConf) { | |||||
| const useChildrenMap = new Map<string, BrickConf[]>(); | ||||||
| if (Array.isArray(brick.children) && !slots) { | ||||||
| const removeBricks: BrickConf[] = []; | ||||||
| for (const child of brick.children) { | ||||||
| for (const child of brick.children as BrickConf[]) { | ||||||
weareoutman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| for (const child of brick.children as BrickConf[]) { | |
| for (const child of brick.children.filter((c): c is BrickConf => !!(c as BrickConf).brick)) { |
Uh oh!
There was an error while loading. Please reload this page.