Skip to content

Loading…

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

Merged
merged 1 commit into from

2 participants

@3rd-Eden

Don't check against the window to detect node.js, wrap code in a try catch statement and have it degrade gracefully like the rest of the code.

Fixes #147

@3rd-Eden 3rd-Eden Don't check against the window to detect node.js, wrap code in a try …
…catch statement

and have it degrade gracefully.

Fixes #147
3c6eb2a
@rauchg

Excellent. Do we have other instances where it would make sense to have a similar approach?

@rauchg rauchg merged commit b5c982c into socketio:master
@3rd-Eden 3rd-Eden deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 26, 2013
  1. @3rd-Eden

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

    3rd-Eden committed
    …catch statement
    
    and have it degrade gracefully.
    
    Fixes #147
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/util.js
View
4 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();
Something went wrong with that request. Please try again.