Skip to content

Commit

Permalink
simplify handleclick;
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Feb 14, 2024
1 parent 2d7da01 commit 3e70e4d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/tab-container-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,11 @@ export class TabContainerElement extends HTMLElement {
}

#handleClick(event: MouseEvent) {
const tab = (event.target as HTMLElement)?.closest?.('[role="tab"]')
if (!tab) return
const tabs = this.#tabs

if (!(event.target instanceof Element)) return
if (event.target.closest(this.tagName) !== this) return

const tab = event.target.closest('[role="tab"]')
if (!(tab instanceof HTMLElement) || (!tab.closest('[role="tablist"]') && !tab.assignedSlot)) {
return
}

const index = tabs.indexOf(tab)
const index = tabs.indexOf(tab as HTMLElement)
if (index < 0) return
this.selectTab(index)
}

Expand Down

0 comments on commit 3e70e4d

Please sign in to comment.