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

Commit 2766252

Browse files
committed
polyfill handling
1 parent a0ee0f4 commit 2766252

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

Gruntfile.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module.exports = function (grunt) {
2121
dist: {
2222
files: {
2323
'dist/<%= pkg.name %>.src.js': [
24-
'node_modules/when/es6-shim/Promise.js',
2524
'src/wrapper-start.js',
2625
'src/loader.js',
2726
'src/dynamic-only.js',
@@ -32,7 +31,6 @@ module.exports = function (grunt) {
3231
'src/wrapper-end.js'
3332
],
3433
'dist/<%= pkg.name %>-dev.src.js': [
35-
'node_modules/when/es6-shim/Promise.js',
3634
'src/wrapper-start.js',
3735
'src/loader.js',
3836
'src/declarative.js',

src/url-polyfill.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// from https://gist.github.com/Yaffle/1088850
2-
function URL(url, baseURL) {
2+
function URLPolyfill(url, baseURL) {
33
if (typeof url != 'string')
44
throw new TypeError('URL must be a string');
55
var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
@@ -64,4 +64,5 @@ function URL(url, baseURL) {
6464
this.pathname = pathname;
6565
this.search = search;
6666
this.hash = hash;
67-
}
67+
}
68+
(typeof self != 'undefined' ? self : global).URLPolyfill = URLPolyfill;

src/wrapper-end.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818

1919
__global.System = System;
2020

21-
})(typeof window != 'undefined' ? window : (typeof global != 'undefined' ? global : self));
21+
})(typeof self != 'undefined' ? self : global);

src/wrapper-start.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@
5555
throw addToError(e, 'Evaluating ' + debugName);
5656
}
5757
}
58+
59+
var URL = __global.URL || URLPolyfill;

test/system.normalize.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ describe('System', function () {
4747

4848
describe('when having two arguments', function () {
4949

50-
var refererAddress = '/dir/file';
50+
var refererAddress = 'http://parent.com/dir/file';
5151

5252
it('should normalize relative paths against the parent address', function () {
53-
expect(System.normalize('./d/e/f', null, refererAddress)).to.equal('/dir/d/e/f');
54-
expect(System.normalize('../e/f', null, refererAddress)).to.equal('/e/f');
53+
expect(System.normalize('./d/e/f', null, refererAddress)).to.equal('http://parent.com/dir/d/e/f');
54+
expect(System.normalize('../e/f', null, refererAddress)).to.equal('http://parent.com/e/f');
5555
});
5656

5757
});

0 commit comments

Comments
 (0)