Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JavaScript errors when entering text into the Character Count in IE8 #2909

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

36degrees
Copy link
Contributor

The Character Count makes use of Date.now to record the time of the last input to the textarea, debouncing screen reader updates to prevent them from being read too often or queued up.

However, Date.now is not supported in IE8.

This causes a script error on the keyup event when typing in to the Character Count, although the script continues to run.

Add a polyfill for Date.now based on Polyfill.io's implementation, adapted to match the format used for the existing polyfills.

Closes #2904.

The Character Count makes use of `Date.now` [1] to record the time of the last input to the textarea, debouncing screen reader updates to prevent them from being read too often or queued up.

However, `Date.now` is not supported in IE8 [2].

This causes a script error on the `keyup` event when typing in to the Character Count, although the script continues to run.

Add a polyfill for `Date.now` based on Polyfill.io's implementation [3], adapted to match the format used for the existing polyfills.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now
[2]: https://caniuse.com/mdn-javascript_builtins_date_now
[3]: https://polyfill.io/v3/polyfill.js?version=3.111.0&features=Date.now&flags=always
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2909 October 10, 2022 16:14 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2909 October 10, 2022 16:16 Inactive
@36degrees 36degrees merged commit f199990 into main Oct 11, 2022
@36degrees 36degrees deleted the date-now-polyfill branch October 11, 2022 08:40
@romaricpascal romaricpascal mentioned this pull request Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Character Count uses Date.now which is not supported in IE8
3 participants