Skip to content

Commit aefeb54

Browse files
Cleanup docs add missing CSS
1 parent 729c5f9 commit aefeb54

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/components/navigation/IonTabs.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export default {
2828
continue;
2929
}
3030

31-
// Render, cache or ignore ion-tabs
3231
const tabName = matchRouteToTab(vnode, route);
3332
const tabIsCached = cachedTabs[i];
3433

@@ -55,6 +54,7 @@ export default {
5554
Vue.nextTick(() => {
5655
for (let i = 0; i < postRenderQueue.length; i++) {
5756
const vnode = postRenderQueue[i];
57+
5858
if (vnode && vnode.elm && vnode.elm.nodeName === 'ION-TAB') {
5959
const ionTab = vnode.elm as HTMLIonTabElement;
6060
const vnodeData = {
@@ -63,6 +63,8 @@ export default {
6363
},
6464
};
6565
const tabName = matchRouteToTab(vnodeData as any, route);
66+
67+
// Set tab active state
6668
ionTab.active = !!tabName;
6769

6870
// Loop through all tab-bars and set active tab
@@ -119,10 +121,11 @@ function parseTabBar(vnode: VNode, tab: string): VNode {
119121
}
120122

121123
// Loop through ion-tab-buttons and assign click handlers
124+
// If custom click handler was provided, do not override it
122125
if (vnode.children) {
123126
for (const child of vnode.children) {
124127
if (child.tag && child.tag === 'ion-tab-button') {
125-
if (!child.data || !child.data!.on || !child.data!.on!.click) {
128+
if (!child.data || !child.data.on || !child.data.on.click) {
126129
Object.assign(child.data, {
127130
on: {
128131
click: (e: Event) => {
@@ -144,18 +147,21 @@ function parseTabBar(vnode: VNode, tab: string): VNode {
144147
return vnode;
145148
}
146149

147-
function hasDataAttr(child: VNode, attr: string) {
148-
return child.data && child.data.attrs && child.data.attrs[attr];
150+
// Check if a VNode has a specific attribute set
151+
function hasDataAttr(vnode: VNode, attr: string) {
152+
return vnode.data && vnode.data.attrs && vnode.data.attrs[attr];
149153
}
150154

155+
// Match tab to route through :routes property
156+
// Otherwise match by URL
151157
function matchRouteToTab(vnode: VNode, route: Route): string {
152158
if (!vnode.data || !vnode.data.attrs || !vnode.data.attrs.tab) {
153159
throw new Error('The tab attribute is required for an ion-tab element');
154160
}
155161

156162
const tabName = vnode.data.attrs.tab;
157163

158-
// Handle route matching by provided attribute
164+
// Handle route matching by :routes attribute
159165
if (vnode.data.attrs.routes) {
160166
const routes = Array.isArray(vnode.data.attrs.routes)
161167
? vnode.data.attrs.routes
@@ -176,6 +182,7 @@ function matchRouteToTab(vnode: VNode, route: Route): string {
176182
return '';
177183
}
178184

185+
// CSS for ion-tabs inner and outer elements
179186
const hostStyles = {
180187
display: 'flex',
181188
position: 'absolute',
@@ -186,9 +193,11 @@ const hostStyles = {
186193
flexDirection: 'column',
187194
width: '100%',
188195
height: '100%',
196+
contain: 'layout size style',
189197
};
190198

191199
const tabsInner = {
192200
position: 'relative',
193201
flex: 1,
202+
contain: 'layout size style',
194203
};

0 commit comments

Comments
 (0)