Skip to content

Commit

Permalink
Rename new .js files to .mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
querkmachine committed Jun 23, 2022
1 parent ba97460 commit 0697445
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/govuk/i18n.js → src/govuk/i18n.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './vendor/polyfills/Array/prototype/indexOf'
import './vendor/polyfills/Array/prototype/indexOf.mjs'

/**
* i18n support initialisation function
Expand Down
29 changes: 0 additions & 29 deletions src/govuk/vendor/polyfills/Array/prototype/indexOf.js

This file was deleted.

27 changes: 27 additions & 0 deletions src/govuk/vendor/polyfills/Array/prototype/indexOf.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(function (undefined) {
var detect = (
'indexOf' in Array.prototype
)

if (detect) return

// Polyfill adapted from https://cdn.polyfill.io/v2/polyfill.js?features=Array.prototype.indexOf&flags=always
Array.prototype.indexOf = function (searchElement, fromIndex) {
fromIndex = Number(fromIndex) || 0

if (this === undefined || this === null) {
throw new TypeError(this + ' is not an object')
}

var array = this instanceof String ? this.split('') : this
var arrayLength = Math.max(Math.min(array.length, 9007199254740991), 0) || 0
var loopStartIndex = (fromIndex < 0 ? Math.max(arrayLength + fromIndex, 0) : fromIndex) - 1

for (var i = loopStartIndex; ++i < arrayLength;) {
if (i in array && array[i] === searchElement) {
return i
}
}
return -1
}
}).call(typeof window === 'object' && window || typeof self === 'object' && self || typeof global === 'object' && global || {})
File renamed without changes.

0 comments on commit 0697445

Please sign in to comment.