UNPKG

767 BJavaScriptView Raw
1const Template = require('./Template');
2const XMLHttpRequestRuntime = Template.getFunctionContent(require('./polyfill/XMLHttpRequest'));
3
4module.exports = `
5var global;
6
7if (typeof window !== 'undefined') {
8 global = window;
9} else if (typeof global !== 'undefined') {
10 global = global;
11} else if (typeof self !== 'undefined') {
12 global = self;
13} else {
14 global = {};
15};
16
17
18// reload polyfill
19var isWeex = typeof callNative === 'function';
20
21if (isWeex && typeof location.reload === 'undefined') {
22 var LOCATION_MODULE = '@weex-module/location';
23
24 location.reload = function(forceReload) {
25 var weexLocation = require(LOCATION_MODULE);
26 weexLocation.reload(forceReload);
27 };
28};
29
30if (typeof XMLHttpRequest === 'undefined') {
31 ${XMLHttpRequestRuntime}
32}
33`;