Permalink
Browse files

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

…catch statement

and have it degrade gracefully.

Fixes #147
  • Loading branch information...
1 parent 6878014 commit 3c6eb2a177987f26ab00e73cdcc457f3ceebbe29 @3rd-Eden committed Mar 26, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/util.js
View
@@ -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();

0 comments on commit 3c6eb2a

Please sign in to comment.