IE11 support updates (#18)

* IE11 support updates

* Fix Object.values IE11 support

* forEach

* Object.values

* Array.includes
This commit is contained in:
Eric Jinks 2018-05-30 10:44:56 +10:00 committed by GitHub
parent 3c2516a158
commit 052afdeb10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 10 deletions

View file

@ -1,3 +1,7 @@
## 0.2.9 - 2018-05-30
* IE11 support updates
## 0.2.8 - 2018-05-29
* Use imgix auto=format for automatic webp conversion

View file

@ -33,9 +33,9 @@
<script>
// check for netlifyIdentity, redirect to admin if user is logging in
if (window.localStorage && window.netlifyIdentity) {
netlifyIdentity.on('init', user => {
netlifyIdentity.on('init', function (user) {
if (!user) {
netlifyIdentity.on('login', () => {
netlifyIdentity.on('login', function () {
document.location.href = '/admin/'
})
}

View file

@ -32,7 +32,7 @@ class Form extends Component {
componentDidMount () {
if (!this.form) return
this.inputs = this.form.querySelectorAll('input, textarea')
this.inputs = [...this.form.querySelectorAll('input, textarea')]
this.addListeners()
}

View file

@ -1,9 +1,5 @@
/* global URL, fetch, Event */
const swReady = new Event('swReady')
const swUpdated = new Event('swUpdated')
const swOffline = new Event('swOffline')
// In production, we register a service worker to serve assets from local cache.
// This lets the app load faster on subsequent visits in production, and gives
@ -24,9 +20,16 @@ const isLocalhost = Boolean(
)
)
let swReady, swUpdated, swOffline
export default function register () {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
swReady = new Event('swReady')
swUpdated = new Event('swUpdated')
swOffline = new Event('swOffline')
const publicUrl = new URL(process.env.PUBLIC_URL, window.location)
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin

View file

@ -1,5 +1,7 @@
import _uniq from 'lodash/uniq'
import _kebabCase from 'lodash/kebabCase'
import _values from 'lodash/values'
import _includes from 'lodash/includes'
export const getCollectionTerms = (
collection = [],
@ -18,7 +20,7 @@ export const getCollectionTerms = (
const collectionItemTerms =
typeof termField === 'string'
? termField.split(',').map(term => _kebabCase(term.trim()))
: termField.map(term => _kebabCase(Object.values(term)[0]))
: termField.map(term => _kebabCase(_values(term)[0]))
return _uniq([...acc, ...collectionItemTerms])
}, [])
.sort()
@ -32,7 +34,7 @@ export const documentHasTerm = (doc, taxonomyName, term) => {
const terms =
typeof termField === 'string'
? termField.split(',').map(term => _kebabCase(term))
: termField.map(term => _kebabCase(Object.values(term)[0]))
: termField.map(term => _kebabCase(_values(term)[0]))
return terms.includes(_kebabCase(term))
return _includes(terms, _kebabCase(term))
}