Problem/Motivation
Our project concerned an online shop with the possibilities to add products to favorites.
When we use Flag module to handle favorites for our project, an error occured when the page is loaded or when we tried to add our product to favorites with IE11.
'SCRIPT438:Object doesn't support property or method 'forEach'
This error is caused by the 12th line of flag-action_link_flash.js script.
Proposed resolution
Change "forEach" method with $.each() one.
Before:
links.forEach(function (link) {
return link.addEventListener('click', function (event) {
return event.target.parentNode.classList.add('flag-waiting');
});
});
After:
$.each(links, function (key, link) {
return link.addEventListener('click', function (event) {
return event.target.parentNode.classList.add('flag-waiting');
});
});
Remaining tasks
Create a patch with this correction and review it with flag community.
Comments
Comment #2
AnaSwin commentedComment #3
gerson.analista commentedI had the same problem, I applied the patch #2, but didn't solve the problem.
I made a small change and generated a new patch.
Comment #4
gerson.analista commentedComment #5
martin107 commentedJust providing context
https://caniuse.com/#search=forEach
When I checked today
ie11 is not suported
and has a global use of 1.39%
Comment #6
ericgsmith commentedLooks like the flag module uses core's js transpile workflow to manage JS so we need to fix the source files rather than the transpiled output.
In doing so - it looks like when the admin file was committed, it wasn't generated, so I've made a small change so that it matches the output.
Note - nodelist.forEach is not supported in ie11, array.forEach is - so I've followed a standard way to convert the node list object to an array.
Comment #7
martin107 commentedAll changes to .es6.js files look OK
and the corresponding transpiled output look good as well.
ericgsmith -- That is a nice touch. Thank you.
Comment #9
berdirThanks, committed. JS is mostly a blackbox for me, so just going to believe you that this fixes the problem ;)
Comment #10
berdir