From 3c6eb2a177987f26ab00e73cdcc457f3ceebbe29 Mon Sep 17 00:00:00 2001 From: 3rd-Eden Date: Tue, 26 Mar 2013 21:41:00 +0100 Subject: [PATCH] Don't check against the window to detect node.js, wrap code in a try catch statement and have it degrade gracefully. Fixes #147 --- lib/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util.js b/lib/util.js index 14f94fbb..3edc2c0f 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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();