alphagov / govuk_frontend_toolkit

❗️GOV.UK Frontend Toolkit is deprecated, and will only receive major bug fixes and security patches.
MIT License
403 stars 107 forks source link

Fix js error causing missing accordions in IE7 #407

Closed 36degrees closed 7 years ago

36degrees commented 7 years ago

Accessing individual characters in strings as if they are arrays is an ECMAScript 5 feature which was only introduced in IE8. So IE 7 and below (and IE11 when in compatibility mode) are erroring because of this.

Notably this is leaving accordions in a state where the original page content has been removed (because they use the js-hidden class), but the accordion fails to initialise, leaving the user with no way to navigate further.

We can fix this by using charAt1 as recommended by MDN 2