Skip to content

Conversation

@hankhero
Copy link

@hankhero hankhero commented Nov 9, 2014

for a web-worker, window is unavailable butXMLHttpRequest is available on the global 'self' object

for a web-worker, window is unavailable butXMLHttpRequest is available on the global 'self' object
@canastro
Copy link

This would be really useful!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this:

if (typeof XMLHttpRequest !== 'undefined') {
    return XMLHttpRequest;
}

And then remove the second check for window.XMLHttpRequest below.

@tschaub
Copy link
Contributor

tschaub commented Aug 19, 2015

Agreed this would be useful. For others looking to work around the window checking, you can add this hack to whatever module requires http:

self.window = self;

And with this, window.XMLHttpRequest will be defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants