mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 18:17:31 +08:00
fix(ie): classList does not support variadic (#19460)
This commit is contained in:
@ -74,16 +74,16 @@ const getClasses = (element: HTMLElement) => {
|
|||||||
|
|
||||||
const setClasses = (element: HTMLElement, classes: string[]) => {
|
const setClasses = (element: HTMLElement, classes: string[]) => {
|
||||||
const classList = element.classList;
|
const classList = element.classList;
|
||||||
|
[
|
||||||
classList.remove(
|
|
||||||
'ion-valid',
|
'ion-valid',
|
||||||
'ion-invalid',
|
'ion-invalid',
|
||||||
'ion-touched',
|
'ion-touched',
|
||||||
'ion-untouched',
|
'ion-untouched',
|
||||||
'ion-dirty',
|
'ion-dirty',
|
||||||
'ion-pristine'
|
'ion-pristine'
|
||||||
);
|
].forEach(c => classList.remove(c));
|
||||||
classList.add(...classes);
|
|
||||||
|
classes.forEach(c => classList.add(c));
|
||||||
};
|
};
|
||||||
|
|
||||||
const startsWith = (input: string, search: string): boolean => {
|
const startsWith = (input: string, search: string): boolean => {
|
||||||
|
@ -230,7 +230,8 @@ export class StackController {
|
|||||||
const leavingEl = leavingView ? leavingView.element : undefined;
|
const leavingEl = leavingView ? leavingView.element : undefined;
|
||||||
const containerEl = this.containerEl;
|
const containerEl = this.containerEl;
|
||||||
if (enteringEl && enteringEl !== leavingEl) {
|
if (enteringEl && enteringEl !== leavingEl) {
|
||||||
enteringEl.classList.add('ion-page', 'ion-page-invisible');
|
enteringEl.classList.add('ion-page');
|
||||||
|
enteringEl.classList.add('ion-page-invisible');
|
||||||
if (enteringEl.parentElement !== containerEl) {
|
if (enteringEl.parentElement !== containerEl) {
|
||||||
containerEl.appendChild(enteringEl);
|
containerEl.appendChild(enteringEl);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ export class Tab implements ComponentInterface {
|
|||||||
this.active = true;
|
this.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async prepareLazyLoaded(): Promise<HTMLElement | undefined> {
|
private prepareLazyLoaded(): Promise<HTMLElement | undefined> {
|
||||||
if (!this.loaded && this.component != null) {
|
if (!this.loaded && this.component != null) {
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
try {
|
try {
|
||||||
@ -57,7 +57,7 @@ export class Tab implements ComponentInterface {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -66,7 +66,7 @@ export class Tabs implements NavOutlet {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
async select(tab: string | HTMLIonTabElement): Promise<boolean> {
|
async select(tab: string | HTMLIonTabElement): Promise<boolean> {
|
||||||
const selectedTab = await this.getTab(tab);
|
const selectedTab = getTab(this.tabs, tab);
|
||||||
if (!this.shouldSwitch(selectedTab)) {
|
if (!this.shouldSwitch(selectedTab)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -84,14 +84,7 @@ export class Tabs implements NavOutlet {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
async getTab(tab: string | HTMLIonTabElement): Promise<HTMLIonTabElement | undefined> {
|
async getTab(tab: string | HTMLIonTabElement): Promise<HTMLIonTabElement | undefined> {
|
||||||
const tabEl = (typeof tab === 'string')
|
return getTab(this.tabs, tab);
|
||||||
? this.tabs.find(t => t.tab === tab)
|
|
||||||
: tab;
|
|
||||||
|
|
||||||
if (!tabEl) {
|
|
||||||
console.error(`tab with id: "${tabEl}" does not exist`);
|
|
||||||
}
|
|
||||||
return tabEl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +98,7 @@ export class Tabs implements NavOutlet {
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
@Method()
|
@Method()
|
||||||
async setRouteId(id: string): Promise<RouteWrite> {
|
async setRouteId(id: string): Promise<RouteWrite> {
|
||||||
const selectedTab = await this.getTab(id);
|
const selectedTab = getTab(this.tabs, id);
|
||||||
if (!this.shouldSwitch(selectedTab)) {
|
if (!this.shouldSwitch(selectedTab)) {
|
||||||
return { changed: false, element: this.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;
|
||||||
|
};
|
||||||
|
@ -77,7 +77,7 @@ export const createKeyframeStylesheet = (keyframeName: string, keyframeRules: st
|
|||||||
|
|
||||||
const stylesheet = (element.ownerDocument || document).createElement('style');
|
const stylesheet = (element.ownerDocument || document).createElement('style');
|
||||||
stylesheet.id = keyframeName;
|
stylesheet.id = keyframeName;
|
||||||
stylesheet.innerHTML = `@keyframes ${keyframeName} { ${keyframeRules} } @keyframes ${keyframeName}-alt { ${keyframeRules} }`;
|
stylesheet.textContent = `@keyframes ${keyframeName} { ${keyframeRules} } @keyframes ${keyframeName}-alt { ${keyframeRules} }`;
|
||||||
|
|
||||||
styleContainer.appendChild(stylesheet);
|
styleContainer.appendChild(stylesheet);
|
||||||
|
|
||||||
|
@ -529,8 +529,8 @@ export const createAnimation = () => {
|
|||||||
elements.forEach((el: HTMLElement) => {
|
elements.forEach((el: HTMLElement) => {
|
||||||
const elementClassList = el.classList;
|
const elementClassList = el.classList;
|
||||||
|
|
||||||
elementClassList.add(...addClasses);
|
addClasses.forEach(c => elementClassList.add(c));
|
||||||
elementClassList.remove(...removeClasses);
|
removeClasses.forEach(c => elementClassList.remove(c));
|
||||||
|
|
||||||
for (const property in styles) {
|
for (const property in styles) {
|
||||||
if (styles.hasOwnProperty(property)) {
|
if (styles.hasOwnProperty(property)) {
|
||||||
@ -578,8 +578,8 @@ export const createAnimation = () => {
|
|||||||
elements.forEach((el: HTMLElement) => {
|
elements.forEach((el: HTMLElement) => {
|
||||||
const elementClassList = el.classList;
|
const elementClassList = el.classList;
|
||||||
|
|
||||||
elementClassList.add(...addClasses);
|
addClasses.forEach(c => elementClassList.add(c));
|
||||||
elementClassList.remove(...removeClasses);
|
removeClasses.forEach(c => elementClassList.remove(c));
|
||||||
|
|
||||||
for (const property in styles) {
|
for (const property in styles) {
|
||||||
if (styles.hasOwnProperty(property)) {
|
if (styles.hasOwnProperty(property)) {
|
||||||
|
@ -122,7 +122,8 @@ function transition(parent: Vue, props: Props, leavingEl: HTMLElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the proper Ionic classes, important for smooth transitions
|
// Add the proper Ionic classes, important for smooth transitions
|
||||||
enteringEl.classList.add('ion-page', 'ion-page-invisible');
|
enteringEl.classList.add('ion-page');
|
||||||
|
enteringEl.classList.add('ion-page-invisible');
|
||||||
|
|
||||||
// Commit to the transition as soon as the Ionic Router Outlet is ready
|
// Commit to the transition as soon as the Ionic Router Outlet is ready
|
||||||
return ionRouterOutlet.componentOnReady().then((el: HTMLIonRouterOutletElement) => {
|
return ionRouterOutlet.componentOnReady().then((el: HTMLIonRouterOutletElement) => {
|
||||||
|
Reference in New Issue
Block a user