Skip to content

Commit

Permalink
Qualify query selectors to infer HTMLAnchorElement type
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Feb 10, 2023
1 parent 0d8c0d6 commit 5c134f9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/govuk/components/tabs/tabs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Tabs ($module) {
return this
}

var $tabs = $module.querySelectorAll('.govuk-tabs__tab')
var $tabs = $module.querySelectorAll('a.govuk-tabs__tab')
if (!$tabs.length) {
return this
}
Expand Down Expand Up @@ -123,7 +123,7 @@ Tabs.prototype.teardown = function () {
var $module = this.$module
var $tabs = this.$tabs
var $tabList = $module.querySelector('.govuk-tabs__list')
var $tabListItems = $module.querySelectorAll('.govuk-tabs__list-item')
var $tabListItems = $module.querySelectorAll('a.govuk-tabs__list-item')

if (!$tabs || !$tabList || !$tabListItems) {
return
Expand Down Expand Up @@ -204,7 +204,7 @@ Tabs.prototype.showTab = function ($tab) {
* @returns {HTMLAnchorElement | null} Tab link
*/
Tabs.prototype.getTab = function (hash) {
return this.$module.querySelector('.govuk-tabs__tab[href="' + hash + '"]')
return this.$module.querySelector('a.govuk-tabs__tab[href="' + hash + '"]')
}

/**
Expand Down Expand Up @@ -337,7 +337,7 @@ Tabs.prototype.activateNextTab = function () {
return
}

var $nextTab = $nextTabListItem.querySelector('.govuk-tabs__tab')
var $nextTab = $nextTabListItem.querySelector('a.govuk-tabs__tab')
if (!$nextTab) {
return
}
Expand All @@ -362,7 +362,7 @@ Tabs.prototype.activatePreviousTab = function () {
return
}

var $previousTab = $previousTabListItem.querySelector('.govuk-tabs__tab')
var $previousTab = $previousTabListItem.querySelector('a.govuk-tabs__tab')
if (!$previousTab) {
return
}
Expand Down Expand Up @@ -447,7 +447,7 @@ Tabs.prototype.highlightTab = function ($tab) {
* @returns {HTMLAnchorElement | null} Tab link
*/
Tabs.prototype.getCurrentTab = function () {
return this.$module.querySelector('.govuk-tabs__list-item--selected .govuk-tabs__tab')
return this.$module.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab')
}

/**
Expand Down

0 comments on commit 5c134f9

Please sign in to comment.