From 5c134f9252913b11bc2a43e20dce7e53a5ac078b Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Mon, 6 Feb 2023 17:44:09 +0000 Subject: [PATCH] Qualify query selectors to infer `HTMLAnchorElement` type --- src/govuk/components/tabs/tabs.mjs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/govuk/components/tabs/tabs.mjs b/src/govuk/components/tabs/tabs.mjs index fea5725040..31dfc51122 100644 --- a/src/govuk/components/tabs/tabs.mjs +++ b/src/govuk/components/tabs/tabs.mjs @@ -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 } @@ -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 @@ -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 + '"]') } /** @@ -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 } @@ -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 } @@ -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') } /**