55 lines
2.4 KiB
JavaScript
55 lines
2.4 KiB
JavaScript
|
|
'use strict';
|
||
|
|
|
||
|
|
exports.__esModule = true;
|
||
|
|
var canUseDOM = exports.canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
||
|
|
|
||
|
|
var addEventListener = exports.addEventListener = function addEventListener(node, event, listener) {
|
||
|
|
return node.addEventListener ? node.addEventListener(event, listener, false) : node.attachEvent('on' + event, listener);
|
||
|
|
};
|
||
|
|
|
||
|
|
var removeEventListener = exports.removeEventListener = function removeEventListener(node, event, listener) {
|
||
|
|
return node.removeEventListener ? node.removeEventListener(event, listener, false) : node.detachEvent('on' + event, listener);
|
||
|
|
};
|
||
|
|
|
||
|
|
var getConfirmation = exports.getConfirmation = function getConfirmation(message, callback) {
|
||
|
|
return callback(window.confirm(message));
|
||
|
|
}; // eslint-disable-line no-alert
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Returns true if the HTML5 history API is supported. Taken from Modernizr.
|
||
|
|
*
|
||
|
|
* https://github.com/Modernizr/Modernizr/blob/master/LICENSE
|
||
|
|
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
|
||
|
|
* changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
|
||
|
|
*/
|
||
|
|
var supportsHistory = exports.supportsHistory = function supportsHistory() {
|
||
|
|
var ua = window.navigator.userAgent;
|
||
|
|
|
||
|
|
if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false;
|
||
|
|
|
||
|
|
return window.history && 'pushState' in window.history;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Returns true if browser fires popstate on hash change.
|
||
|
|
* IE10 and IE11 do not.
|
||
|
|
*/
|
||
|
|
var supportsPopStateOnHashChange = exports.supportsPopStateOnHashChange = function supportsPopStateOnHashChange() {
|
||
|
|
return window.navigator.userAgent.indexOf('Trident') === -1;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Returns false if using go(n) with hash history causes a full page reload.
|
||
|
|
*/
|
||
|
|
var supportsGoWithoutReloadUsingHash = exports.supportsGoWithoutReloadUsingHash = function supportsGoWithoutReloadUsingHash() {
|
||
|
|
return window.navigator.userAgent.indexOf('Firefox') === -1;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Returns true if a given popstate event is an extraneous WebKit event.
|
||
|
|
* Accounts for the fact that Chrome on iOS fires real popstate events
|
||
|
|
* containing undefined state when pressing the back button.
|
||
|
|
*/
|
||
|
|
var isExtraneousPopstateEvent = exports.isExtraneousPopstateEvent = function isExtraneousPopstateEvent(event) {
|
||
|
|
return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;
|
||
|
|
};
|