Skip to content

Commit

Permalink
Merge pull request #2909 from alphagov/date-now-polyfill
Browse files Browse the repository at this point in the history
Fix JavaScript errors when entering text into the Character Count in IE8
  • Loading branch information
36degrees authored Oct 11, 2022
2 parents eebe25f + 277aab1 commit f199990
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ We’ve made fixes to GOV.UK Frontend in the following pull requests:
- [#2811: Use Element.id to get module id for accordion](https://github.com/alphagov/govuk-frontend/pull/2811)
- [#2821: Avoid duplicated --error class on Character Count](https://github.com/alphagov/govuk-frontend/pull/2821)
- [#2800: Improve Pagination component print styles](https://github.com/alphagov/govuk-frontend/pull/2800)
- [#2909: Fix JavaScript errors when entering text into the Character Count in IE8](https://github.com/alphagov/govuk-frontend/pull/2909)

## 4.3.1 (Patch release)

Expand Down
1 change: 1 addition & 0 deletions src/govuk/components/character-count/character-count.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '../../vendor/polyfills/Date/now.mjs'
import '../../vendor/polyfills/Function/prototype/bind.mjs'
import '../../vendor/polyfills/Event.mjs' // addEventListener and event.target normalisation
import '../../vendor/polyfills/Element/prototype/classList.mjs'
Expand Down
13 changes: 13 additions & 0 deletions src/govuk/vendor/polyfills/Date/now.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function(undefined) {

// Detection from https://github.com/Financial-Times/polyfill-library/blob/v3.111.0/polyfills/Date/now/detect.js
var detect = ('Date' in self && 'now' in self.Date && 'getTime' in self.Date.prototype)

if (detect) return

// Polyfill from https://polyfill.io/v3/polyfill.js?version=3.111.0&features=Date.now&flags=always
Date.now = function () {
return new Date().getTime();
};

}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});

0 comments on commit f199990

Please sign in to comment.