From f68eb593a1e6c9e59f3f7e7274f4d2530297927b Mon Sep 17 00:00:00 2001 From: Dilwoar Hussain Date: Wed, 27 Jul 2022 12:03:30 +0100 Subject: [PATCH] Fixes incorrectly applied .forEach `.forEach` was incorrectly made available to all DOM Iterators in core-js. This has now been fixed in the package: https://github.com/zloirock/core-js/issues/988 The recommended approach for HTMLCollections objects is to use `Array.from` (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection). This has been applied to the code to support the `.forEach` function. This was originally noticed when updating the yarn.lock file in PR #2551. Credits: @ollietreend for finding the solution. --- app/assets/javascripts/components/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/components/autocomplete.js b/app/assets/javascripts/components/autocomplete.js index 44b89284f0..2923894e0a 100644 --- a/app/assets/javascripts/components/autocomplete.js +++ b/app/assets/javascripts/components/autocomplete.js @@ -36,7 +36,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}; id: $select.id, source: function (query, syncResults) { var results = [] - $select.options.forEach(function ($el) { + Array.from($select.options).forEach(function ($el) { results.push({ text: $el.textContent, hint: $el.dataset.hint || '', value: $el.value }) }) var resultMatcher = function (result) {