Skip to content

Commit 7f72601

Browse files
committed
enhancement(Tabs) coding standards eslint fixes #506
1 parent ea59cdc commit 7f72601

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/tabs.ts

+14-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface TabsOptions extends BaseOptions {
2626
responsiveThreshold: number;
2727
};
2828

29-
let _defaults: TabsOptions = {
29+
const _defaults: TabsOptions = {
3030
duration: 300,
3131
onShow: null,
3232
swipeable: false,
@@ -39,9 +39,9 @@ export class Tabs extends Component<TabsOptions> {
3939
_indicator: HTMLLIElement;
4040
_tabWidth: number;
4141
_tabsWidth: number;
42-
_tabsCarousel: any;
43-
_activeTabLink: any;
44-
_content: any;
42+
_tabsCarousel: Carousel;
43+
_activeTabLink: HTMLAnchorElement;
44+
_content: HTMLElement;
4545

4646
constructor(el: HTMLElement, options: Partial<TabsOptions>) {
4747
super(el, options, Tabs);
@@ -135,12 +135,12 @@ export class Tabs extends Component<TabsOptions> {
135135

136136
if (!tabLink)
137137
return;
138-
var tab = tabLink.parentElement;
138+
let tab = tabLink.parentElement;
139139
while (tab && !tab.classList.contains('tab')) {
140140
tabLink = tabLink.parentElement as HTMLAnchorElement;
141141
tab = tab.parentElement;
142142
}
143-
143+
144144
// Handle click on tab link only
145145
if (!tabLink || !tab.classList.contains('tab')) return;
146146
// is disabled?
@@ -204,18 +204,19 @@ export class Tabs extends Component<TabsOptions> {
204204
this._activeTabLink = Array.from(this._tabLinks).find((a: HTMLAnchorElement) => a.getAttribute('href') === location.hash);
205205
// If no match is found, use the first link or any with class 'active' as the initial active tab.
206206
if (!this._activeTabLink) {
207-
this._activeTabLink = this.el.querySelector('li.tab a.active');
208-
}
209-
if (this._activeTabLink.length === 0) {
210-
this._activeTabLink = this.el.querySelector('li.tab a');
207+
let activeTabLink = this.el.querySelector('li.tab a.active');
208+
if (!activeTabLink) {
209+
activeTabLink = this.el.querySelector('li.tab a');
210+
}
211+
this._activeTabLink = (activeTabLink as HTMLAnchorElement);
211212
}
212213
Array.from(this._tabLinks).forEach((a: HTMLAnchorElement) => a.classList.remove('active'));
213214
this._activeTabLink.classList.add('active');
214215

215216
this._index = Math.max(Array.from(this._tabLinks).indexOf(this._activeTabLink), 0);
216217
if (this._activeTabLink && this._activeTabLink.hash) {
217218
this._content = document.querySelector(this._activeTabLink.hash);
218-
if (this._content)
219+
if (this._content)
219220
this._content.classList.add('active');
220221
}
221222
}
@@ -230,7 +231,7 @@ export class Tabs extends Component<TabsOptions> {
230231
if (a.hash) {
231232
const currContent = document.querySelector(a.hash);
232233
currContent.classList.add('carousel-item');
233-
tabsContent.push(currContent);
234+
tabsContent.push(currContent);
234235
}
235236
});
236237

@@ -271,7 +272,7 @@ export class Tabs extends Component<TabsOptions> {
271272
const tabsWrapper = this._tabsCarousel.el;
272273
this._tabsCarousel.destroy();
273274
// Unwrap
274-
tabsWrapper.after(tabsWrapper.children);
275+
tabsWrapper.append(tabsWrapper.parentElement);
275276
tabsWrapper.remove();
276277
}
277278

0 commit comments

Comments
 (0)