|
59 | 59 | }
|
60 | 60 |
|
61 | 61 | var fetchTextFromURL;
|
62 |
| - if (isBrowser || isWorker) { |
| 62 | + if (typeof XMLHttpRequest != 'undefined') { |
63 | 63 | fetchTextFromURL = function(url, fulfill, reject) {
|
64 | 64 | var xhr = new XMLHttpRequest();
|
65 | 65 | var sameDomain = true;
|
|
72 | 72 | sameDomain &= domainCheck[1] === window.location.protocol;
|
73 | 73 | }
|
74 | 74 | }
|
75 |
| - if (!sameDomain) { |
| 75 | + if (!sameDomain && typeof XDomainRequest != 'undefined') { |
76 | 76 | xhr = new XDomainRequest();
|
77 | 77 | xhr.onload = load;
|
78 | 78 | xhr.onerror = error;
|
|
102 | 102 | xhr.send(null);
|
103 | 103 | }
|
104 | 104 | }
|
105 |
| - else { |
| 105 | + else if (typeof require != 'undefined') { |
106 | 106 | var fs;
|
107 | 107 | fetchTextFromURL = function(url, fulfill, reject) {
|
108 | 108 | fs = fs || require('fs');
|
|
114 | 114 | });
|
115 | 115 | }
|
116 | 116 | }
|
| 117 | + else { |
| 118 | + throw new TypeError('No environment fetch API available.'); |
| 119 | + } |
117 | 120 |
|
118 | 121 | class SystemLoader extends __global.LoaderPolyfill {
|
119 | 122 |
|
120 | 123 | constructor(options) {
|
121 | 124 | super(options || {});
|
122 | 125 |
|
123 | 126 | // Set default baseURL and paths
|
124 |
| - if (isBrowser || isWorker) { |
| 127 | + if (typeof location != 'undefined' && location.href) { |
125 | 128 | var href = __global.location.href.split('#')[0].split('?')[0];
|
126 | 129 | this.baseURL = href.substring(0, href.lastIndexOf('/') + 1);
|
127 | 130 | }
|
128 |
| - else { |
| 131 | + else if (typeof process != 'undefined' && process.cwd) { |
129 | 132 | this.baseURL = process.cwd() + '/';
|
130 | 133 | }
|
| 134 | + else { |
| 135 | + throw new TypeError('No environment baseURL'); |
| 136 | + } |
131 | 137 | this.paths = { '*': '*.js' };
|
132 | 138 | }
|
133 | 139 |
|
|
255 | 261 |
|
256 | 262 | // <script type="module"> support
|
257 | 263 | // allow a data-init function callback once loaded
|
258 |
| - if (isBrowser) { |
| 264 | + if (isBrowser && typeof document.getElementsByTagName != 'undefined') { |
259 | 265 | var curScript = document.getElementsByTagName('script');
|
260 | 266 | curScript = curScript[curScript.length - 1];
|
261 | 267 |
|
|
0 commit comments