Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 9ae32c4

Browse files
committed
make baseURL a loader constructor option
1 parent 80c2119 commit 9ae32c4

File tree

2 files changed

+24
-36
lines changed

2 files changed

+24
-36
lines changed

src/loader.js

-13
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@
2020

2121
function Module() {}
2222
function Loader(options) {
23-
options = options || {};
24-
25-
if (options.normalize)
26-
this.normalize = options.normalize;
27-
if (options.locate)
28-
this.locate = options.locate;
29-
if (options.fetch)
30-
this.fetch = options.fetch;
31-
if (options.translate)
32-
this.translate = options.translate;
33-
if (options.instantiate)
34-
this.instantiate = options.instantiate;
35-
3623
this._loader = {
3724
loaderObj: this,
3825
loads: [],

src/system.js

+24-23
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,34 @@
1212

1313
var System;
1414

15-
function SystemLoader(options) {
16-
Loader.call(this, options || {});
15+
function SystemLoader(baseURL) {
16+
Loader.call(this);
1717

18-
var baseURL;
1918
// Set default baseURL and paths
20-
if (typeof document != 'undefined' && document.getElementsByTagName) {
21-
baseURL = document.baseURI;
19+
if (!baseURL) {
20+
if (typeof document != 'undefined' && document.getElementsByTagName) {
21+
baseURL = document.baseURI;
2222

23-
if (!baseURL) {
24-
var bases = document.getElementsByTagName('base');
25-
baseURL = bases[0] && bases[0].href || window.location.href;
26-
}
23+
if (!baseURL) {
24+
var bases = document.getElementsByTagName('base');
25+
baseURL = bases[0] && bases[0].href || window.location.href;
26+
}
2727

28-
// sanitize out the hash and querystring
29-
baseURL = baseURL.split('#')[0].split('?')[0];
30-
baseURL = baseURL.substr(0, baseURL.lastIndexOf('/') + 1);
31-
}
32-
else if (typeof process != 'undefined' && process.cwd) {
33-
baseURL = 'file://' + (isWindows ? '/' : '') + process.cwd() + '/';
34-
if (isWindows)
35-
baseURL = baseURL.replace(/\\/g, '/');
36-
}
37-
else if (typeof location != 'undefined') {
38-
baseURL = __global.location.href;
39-
}
40-
else {
41-
throw new TypeError('No environment baseURL');
28+
// sanitize out the hash and querystring
29+
baseURL = baseURL.split('#')[0].split('?')[0];
30+
baseURL = baseURL.substr(0, baseURL.lastIndexOf('/') + 1);
31+
}
32+
else if (typeof process != 'undefined' && process.cwd) {
33+
baseURL = 'file://' + (isWindows ? '/' : '') + process.cwd() + '/';
34+
if (isWindows)
35+
baseURL = baseURL.replace(/\\/g, '/');
36+
}
37+
else if (typeof location != 'undefined') {
38+
baseURL = __global.location.href;
39+
}
40+
else {
41+
throw new TypeError('No environment baseURL');
42+
}
4243
}
4344

4445
this.baseURL = baseURL;

0 commit comments

Comments
 (0)