Skip to content

Commit b668eec

Browse files
committed
fix(vue): account for vue 3.2 fix
1 parent 1688d6e commit b668eec

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

packages/vue/src/components/IonTabs.ts

+26-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ const DID_CHANGE = "ionTabsDidChange";
66

77
// TODO(FW-2969): types
88

9+
/**
10+
* Vue 3.2.38 fixed an issue where Web Component
11+
* names are respected using kebab case instead of pascal case.
12+
* As a result, we need to account for both here since we support
13+
* versions of Vue < 3.2.38.
14+
*/
15+
const isRouterOutlet = (node: VNode) => {
16+
return (
17+
node.type &&
18+
((node.type as any).name === "IonRouterOutlet" ||
19+
node.type === "ion-router-outlet")
20+
);
21+
};
22+
23+
const isTabBar = (node: VNode) => {
24+
return (
25+
node.type &&
26+
((node.type as any).name === "IonTabBar" || node.type === "ion-tab-bar")
27+
);
28+
};
29+
930
export const IonTabs = /*@__PURE__*/ defineComponent({
1031
name: "IonTabs",
1132
emits: [WILL_CHANGE, DID_CHANGE],
@@ -19,9 +40,8 @@ export const IonTabs = /*@__PURE__*/ defineComponent({
1940
* inside of ion-tabs.
2041
*/
2142
if (slottedContent && slottedContent.length > 0) {
22-
routerOutlet = slottedContent.find(
23-
(child: VNode) =>
24-
child.type && (child.type as any).name === "IonRouterOutlet"
43+
routerOutlet = slottedContent.find((child: VNode) =>
44+
isRouterOutlet(child)
2545
);
2646
}
2747

@@ -57,13 +77,11 @@ export const IonTabs = /*@__PURE__*/ defineComponent({
5777
* since that needs to be inside of `.tabs-inner`.
5878
*/
5979
const filteredContent = slottedContent.filter(
60-
(child: VNode) =>
61-
!child.type ||
62-
(child.type && (child.type as any).name !== "IonRouterOutlet")
80+
(child: VNode) => !child.type || !isRouterOutlet(child)
6381
);
6482

65-
const slottedTabBar = filteredContent.find(
66-
(child: VNode) => child.type && (child.type as any).name === "IonTabBar"
83+
const slottedTabBar = filteredContent.find((child: VNode) =>
84+
isTabBar(child)
6785
);
6886
const hasTopSlotTabBar =
6987
slottedTabBar && slottedTabBar.props?.slot === "top";

0 commit comments

Comments
 (0)