-
Notifications
You must be signed in to change notification settings - Fork 185
Use API functions based on availability #228
Changes from all commits
25b10d7
798e11c
0a070b0
1d482d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ function __eval(__source, __global, load) { | |
// Hijack System.register to set declare function | ||
var __curRegister = System.register; | ||
System.register = function(name, deps, declare) { | ||
if (typeof name != 'string') { | ||
if (typeof name != 'string' && typeof name != 'void') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is outputting a void in the System.register name? That should never happen and if it does that is the wrong output mode in Traceur (this sounds like the Traceur There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, that is a good question. You're right, name should never be void, that would not make sense. |
||
declare = deps; | ||
deps = name; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ | |
} | ||
|
||
var fetchTextFromURL; | ||
if (isBrowser || isWorker) { | ||
if (typeof XMLHttpRequest != 'undefined') { | ||
fetchTextFromURL = function(url, fulfill, reject) { | ||
var xhr = new XMLHttpRequest(); | ||
var sameDomain = true; | ||
|
@@ -72,7 +72,7 @@ | |
sameDomain &= domainCheck[1] === window.location.protocol; | ||
} | ||
} | ||
if (!sameDomain) { | ||
if (!sameDomain && typeof XDomainRequest != 'undefined') { | ||
xhr = new XDomainRequest(); | ||
xhr.onload = load; | ||
xhr.onerror = error; | ||
|
@@ -102,7 +102,7 @@ | |
xhr.send(null); | ||
} | ||
} | ||
else { | ||
else if (typeof request != 'undefined') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this check necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make sure that the functionality is actually there - there might be a lot of different environments, and I would check the availability of features on a per feature base. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So then shouldn't this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yes, it should :) |
||
var fs; | ||
fetchTextFromURL = function(url, fulfill, reject) { | ||
fs = fs || require('fs'); | ||
|
@@ -114,20 +114,26 @@ | |
}); | ||
} | ||
} | ||
else { | ||
throw new TypeError('No API available to load external resources'); | ||
} | ||
|
||
class SystemLoader extends __global.LoaderPolyfill { | ||
|
||
constructor(options) { | ||
super(options || {}); | ||
|
||
// Set default baseURL and paths | ||
if (isBrowser || isWorker) { | ||
if (typeof __global.location != 'undefined' && typeof __global.location.href != 'undefined') { | ||
var href = __global.location.href.split('#')[0].split('?')[0]; | ||
this.baseURL = href.substring(0, href.lastIndexOf('/') + 1); | ||
} | ||
else { | ||
else if (typeof process != 'undefined' && typeof process.cwd != 'undefined') { | ||
this.baseURL = process.cwd() + '/'; | ||
} | ||
else { | ||
this.baseURL = '.'; | ||
} | ||
this.paths = { '*': '*.js' }; | ||
} | ||
|
||
|
@@ -255,7 +261,7 @@ | |
|
||
// <script type="module"> support | ||
// allow a data-init function callback once loaded | ||
if (isBrowser) { | ||
if (isBrowser && typeof document.getElementsByTagName != 'undefined') { | ||
var curScript = document.getElementsByTagName('script'); | ||
curScript = curScript[curScript.length - 1]; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is in SystemJS in the register extension (https://github.com/systemjs/systemjs/blob/master/lib/extension-register.js#L458).
If you need that functionality, add just the register extension to the module loader from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, will try!