mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
lint(eslint): migrate to eslint and prettier (#25046)
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Listen, Prop, h } from '@stencil/core';
|
||||
import type { ComponentInterface, EventEmitter } from '@stencil/core';
|
||||
import { Component, Element, Event, Host, Listen, Prop, h } from '@stencil/core';
|
||||
|
||||
import { config } from '../../global/config';
|
||||
import { getIonMode } from '../../global/ionic-global';
|
||||
import { TabBarChangedEventDetail, TabButtonClickEventDetail, TabButtonLayout } from '../../interface';
|
||||
import { AnchorInterface } from '../../utils/element-interface';
|
||||
import type { TabBarChangedEventDetail, TabButtonClickEventDetail, TabButtonLayout } from '../../interface';
|
||||
import type { AnchorInterface } from '../../utils/element-interface';
|
||||
|
||||
/**
|
||||
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
|
||||
@ -14,12 +15,11 @@ import { AnchorInterface } from '../../utils/element-interface';
|
||||
tag: 'ion-tab-button',
|
||||
styleUrls: {
|
||||
ios: 'tab-button.ios.scss',
|
||||
md: 'tab-button.md.scss'
|
||||
md: 'tab-button.md.scss',
|
||||
},
|
||||
shadow: true
|
||||
shadow: true,
|
||||
})
|
||||
export class TabButton implements ComponentInterface, AnchorInterface {
|
||||
|
||||
@Element() el!: HTMLElement;
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ export class TabButton implements ComponentInterface, AnchorInterface {
|
||||
const dispatchedFrom = ev.target as HTMLElement;
|
||||
const parent = this.el.parentElement as EventTarget;
|
||||
|
||||
if ((ev.composedPath && ev.composedPath().includes(parent)) || (dispatchedFrom && dispatchedFrom.contains(this.el))) {
|
||||
if (ev.composedPath().includes(parent) || dispatchedFrom?.contains(this.el)) {
|
||||
this.selected = this.tab === ev.detail.tab;
|
||||
}
|
||||
}
|
||||
@ -99,7 +99,7 @@ export class TabButton implements ComponentInterface, AnchorInterface {
|
||||
this.ionTabButtonClick.emit({
|
||||
tab: this.tab,
|
||||
href: this.href,
|
||||
selected: this.selected
|
||||
selected: this.selected,
|
||||
});
|
||||
}
|
||||
ev.preventDefault();
|
||||
@ -115,7 +115,9 @@ export class TabButton implements ComponentInterface, AnchorInterface {
|
||||
}
|
||||
|
||||
private get tabIndex() {
|
||||
if (this.disabled) { return -1; }
|
||||
if (this.disabled) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const hasTabIndex = this.el.hasAttribute('tabindex');
|
||||
|
||||
@ -130,11 +132,11 @@ export class TabButton implements ComponentInterface, AnchorInterface {
|
||||
if (ev.key === 'Enter' || ev.key === ' ') {
|
||||
this.selectTab(ev);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private onClick = (ev: Event) => {
|
||||
this.selectTab(ev);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { disabled, hasIcon, hasLabel, tabIndex, href, rel, target, layout, selected, tab } = this;
|
||||
@ -143,7 +145,7 @@ export class TabButton implements ComponentInterface, AnchorInterface {
|
||||
download: this.download,
|
||||
href,
|
||||
rel,
|
||||
target
|
||||
target,
|
||||
};
|
||||
|
||||
return (
|
||||
@ -165,7 +167,7 @@ export class TabButton implements ComponentInterface, AnchorInterface {
|
||||
[`tab-layout-${layout}`]: true,
|
||||
'ion-activatable': true,
|
||||
'ion-selectable': true,
|
||||
'ion-focusable': true
|
||||
'ion-focusable': true,
|
||||
}}
|
||||
>
|
||||
<a {...attrs} tabIndex={-1} class="button-native" part="native">
|
||||
|
Reference in New Issue
Block a user