From acb643c0132cf048734b752b9b3e895a98259af6 Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Fri, 26 Apr 2024 11:35:31 +0100 Subject: [PATCH] Fix failing test --- .../components/accordion.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/govuk_publishing_components/components/accordion.js b/app/assets/javascripts/govuk_publishing_components/components/accordion.js index c1af633d7f..88ae78c6b1 100644 --- a/app/assets/javascripts/govuk_publishing_components/components/accordion.js +++ b/app/assets/javascripts/govuk_publishing_components/components/accordion.js @@ -1,4 +1,3 @@ -/* global nodeListForEach */ // This component relies on JavaScript from GOV.UK Frontend // = require govuk/components/accordion/accordion.js ;window.GOVUK = window.GOVUK || {} @@ -79,11 +78,12 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion; GemAccordion.prototype.addEventListenersForAnchors = function () { var links = this.$module.querySelectorAll(this.sectionInnerContentClass + ' a[href*="#"]') - nodeListForEach(links, function (link) { + + for(var link of links) { if (link.pathname === window.location.pathname) { link.addEventListener('click', this.openForAnchor.bind(this, link.hash.split('#')[1])) } - }.bind(this)) + } } // Find the parent accordion section for the given id and open it @@ -147,9 +147,10 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion; GemAccordion.prototype.addEventListenerSections = function () { var sections = this.$module.querySelectorAll(this.sectionButton) - nodeListForEach(sections, function (section) { + + for(var section of sections) { section.addEventListener('click', this.addAccordionSectionTracking.bind(this, section)) - }.bind(this)) + } } // If the Accordion's sections are opened on click, then pass them to the GA event tracking