mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 11:41:20 +08:00
fix(vue): pages now render in correct outlet when using multiple nested outlets (#22301)
resolves #22286
This commit is contained in:
@ -6,14 +6,6 @@ import { RouteInfo,
|
||||
|
||||
export const createViewStacks = () => {
|
||||
let viewStacks: ViewStacks = {};
|
||||
const tabsPrefixes = new Set();
|
||||
|
||||
const addTabsPrefix = (prefix: string) => tabsPrefixes.add(prefix);
|
||||
const hasTabsPrefix = (path: string) => {
|
||||
const values = Array.from(tabsPrefixes.values());
|
||||
const hasPrefix = values.find((v: string) => path.includes(v));
|
||||
return hasPrefix !== undefined;
|
||||
}
|
||||
|
||||
const getViewStack = (outletId: number) => {
|
||||
return viewStacks[outletId];
|
||||
@ -31,6 +23,19 @@ export const createViewStacks = () => {
|
||||
return findViewItemByPath(routeInfo.lastPathname, outletId);
|
||||
}
|
||||
|
||||
const findViewItemByMatchedRoute = (matchedRoute: any, outletId: number): ViewItem | undefined => {
|
||||
const stack = viewStacks[outletId];
|
||||
if (!stack) return undefined;
|
||||
|
||||
return stack.find((viewItem: ViewItem) => {
|
||||
if (viewItem.matchedRoute.path === matchedRoute.path) {
|
||||
return viewItem;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
|
||||
const findViewItemInStack = (path: string, stack: ViewItem[]): ViewItem | undefined => {
|
||||
return stack.find((viewItem: ViewItem) => {
|
||||
if (viewItem.pathname === path) {
|
||||
@ -100,9 +105,8 @@ export const createViewStacks = () => {
|
||||
}
|
||||
|
||||
return {
|
||||
addTabsPrefix,
|
||||
hasTabsPrefix,
|
||||
findViewItemByRouteInfo,
|
||||
findViewItemByMatchedRoute,
|
||||
findLeavingViewItemByRouteInfo,
|
||||
createViewItem,
|
||||
getChildrenToRender,
|
||||
|
Reference in New Issue
Block a user