Don't check against the window to detect node.js, wrap code in a try catch statement

and have it degrade gracefully.

Fixes #147
This commit is contained in:
3rd-Eden
2013-03-26 21:41:00 +01:00
parent 68780141ef
commit 3c6eb2a177

View File

@@ -202,10 +202,10 @@ exports.ua.ios6 = exports.ua.ios && /OS 6_/.test(navigator.userAgent);
*/
exports.request = function request (xdomain) {
if ('undefined' == typeof window) {
try {
var _XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
return new _XMLHttpRequest();
}
} catch (e) {}
if (xdomain && 'undefined' != typeof XDomainRequest && !exports.ua.hasCORS) {
return new XDomainRequest();