Skip to content

Commit

Permalink
Fixes incorrectly applied .forEach
Browse files Browse the repository at this point in the history
`.forEach` was incorrectly made available to all DOM Iterators in core-js. This has now been fixed in the package: zloirock/core-js#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.
  • Loading branch information
Dilwoar Hussain committed Jul 27, 2022
1 parent 0d1747f commit f68eb59
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/autocomplete.js
Expand Up @@ -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) {
Expand Down

0 comments on commit f68eb59

Please sign in to comment.