mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-23 11:37:03 -04:00
23 lines
596 B
JavaScript
23 lines
596 B
JavaScript
const win = window; // eslint-disable-line no-undef
|
|
|
|
if (typeof win !== 'object' || win.window !== win || !win.document) {
|
|
throw new Error('no-window');
|
|
}
|
|
|
|
const noBrowser = 'no-browser';
|
|
const doc = win.document;
|
|
const docEl = doc.documentElement;
|
|
docEl.className = '';
|
|
|
|
function assert(expr, hint) {
|
|
if (!expr) {
|
|
docEl.className = noBrowser;
|
|
throw new Error(`${noBrowser}: ${hint}`);
|
|
}
|
|
}
|
|
|
|
assert(!doc.getElementById(noBrowser), 'ie<10');
|
|
assert(typeof Object.assign === 'function', 'assign');
|
|
assert(typeof Promise === 'function', 'promise');
|
|
|
|
module.exports = win;
|