Skip to content

Commit

Permalink
Remove polyfills from govuk-frontend components
Browse files Browse the repository at this point in the history
- Use ES6 for loop in accordion component
  • Loading branch information
MartinJJones committed May 31, 2024
1 parent cc8fe46 commit c017184
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global nodeListForEach */
// = require ../vendor/polyfills/common.js
// This component relies on JavaScript from GOV.UK Frontend
// = require govuk/components/accordion/accordion.bundle.js
window.GOVUK = window.GOVUK || {}
Expand Down Expand Up @@ -80,11 +78,11 @@ 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
Expand Down Expand Up @@ -148,9 +146,9 @@ 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// = require govuk/vendor/polyfills/Element/prototype/closest.js
// = require govuk/components/checkboxes/checkboxes.bundle.js
window.GOVUK = window.GOVUK || {}
window.GOVUK.Modules = window.GOVUK.Modules || {}
Expand Down

0 comments on commit c017184

Please sign in to comment.