FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

support web-workers XMLHttpRequest by hankhero · Pull Request #73 · browserify/http-browserify · GitHub

support web-workers XMLHttpRequest - #73

Open
hankhero wants to merge 1 commit into
browserify:masterfrom
hankhero:master
Open

support web-workers XMLHttpRequest#73
hankhero wants to merge 1 commit into
browserify:masterfrom
hankhero:master

Conversation

hankhero commented Nov 9, 2014

Copy link
Copy Markdown

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

Copy link
Copy Markdown

This would be really useful!

Comment thread index.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

How about this:

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

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

tschaub commented Aug 19, 2015

Copy link
Copy Markdown
Contributor

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.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL