fix(ie): classList does not support variadic (#19460)

This commit is contained in:
Manu MA
2019-09-27 13:12:06 +02:00
committed by GitHub
parent a28e501272
commit b4d92c6241
7 changed files with 29 additions and 23 deletions

View File

@ -66,7 +66,7 @@ export class Tabs implements NavOutlet {
*/
@Method()
async select(tab: string | HTMLIonTabElement): Promise<boolean> {
const selectedTab = await this.getTab(tab);
const selectedTab = getTab(this.tabs, tab);
if (!this.shouldSwitch(selectedTab)) {
return false;
}
@ -84,14 +84,7 @@ export class Tabs implements NavOutlet {
*/
@Method()
async getTab(tab: string | HTMLIonTabElement): Promise<HTMLIonTabElement | undefined> {
const tabEl = (typeof tab === 'string')
? this.tabs.find(t => t.tab === tab)
: tab;
if (!tabEl) {
console.error(`tab with id: "${tabEl}" does not exist`);
}
return tabEl;
return getTab(this.tabs, tab);
}
/**
@ -105,7 +98,7 @@ export class Tabs implements NavOutlet {
/** @internal */
@Method()
async setRouteId(id: string): Promise<RouteWrite> {
const selectedTab = await this.getTab(id);
const selectedTab = getTab(this.tabs, id);
if (!this.shouldSwitch(selectedTab)) {
return { changed: false, element: this.selectedTab };
}
@ -200,3 +193,14 @@ export class Tabs implements NavOutlet {
);
}
}
const getTab = (tabs: HTMLIonTabElement[], tab: string | HTMLIonTabElement): HTMLIonTabElement | undefined => {
const tabEl = (typeof tab === 'string')
? tabs.find(t => t.tab === tab)
: tab;
if (!tabEl) {
console.error(`tab with id: "${tabEl}" does not exist`);
}
return tabEl;
};