accounts-frontend/src/polyfills.js

28 lines
1.1 KiB
JavaScript
Raw Normal View History

import 'babel-polyfill';
import { shim as shimPromiseFinaly } from 'promise.prototype.finally';
2017-03-30 11:35:12 +05:30
const isEdge = /Edge\//.test(navigator.userAgent);
if (isEdge) {
// Edge has a broken fetch implementation, so forcing the polyfill
// https://www.reddit.com/r/webdev/comments/57ii4f/psa_edge_14_ships_a_broken_windowfetch/
// https://github.com/aurelia/fetch-client/issues/81
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9370062/
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7773267/
2017-04-12 10:47:56 +05:30
Reflect.deleteProperty(window, 'fetch');
2017-03-30 11:35:12 +05:30
}
2017-04-12 10:47:56 +05:30
// using require instead of import, because import is hoisting to the top
// so that our fetch hack for Edge won't work
require('whatwg-fetch');
2017-03-30 11:35:12 +05:30
shimPromiseFinaly();
2016-07-30 00:59:27 +05:30
// allow :active styles in mobile Safary
document.addEventListener('touchstart', () => {}, true);
// disable mobile safary back-forward cache
// http://stackoverflow.com/questions/8788802/prevent-safari-loading-from-cache-when-back-button-is-clicked
window.onpageshow = (event) => {
event.persisted && window.location.reload();
};