Problem/Motivation
The syntax for looping over a NodeList
using the forEach method is more concise and useful but is not supported in older browsers, specifically IE11.
As Drupal core uses less and less jQuery to manipulate the DOM, see: #3052002: Replace JQuery with vanilla Javascript in core
it's likely that vanilla JavaScript methods like querySelectorAll or childNodes will be more commonly used by developers.
Proposed resolution
In https://www.drupal.org/project/drupal/issues/3064049#comment-13269867
@justafish suggested using a polyfill like https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill
Remaining tasks
1. Decide where to add the polyfill, for example:
- Always included as part of an existing core library
- Added where needed as a separate library like the matchMedia polyfill
- Or blocked by #2985495: JS: Polyfills support
2. Create the polyfill and test in IE11.