Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable JSONP transport if document is undefined. #283

Closed
wants to merge 1 commit into from

Conversation

tcard
Copy link
Contributor

@tcard tcard commented Jun 8, 2016

This makes the library compatible with React Native.

Fixes #280.

This makes the library compatible with React Native. Fixes #280.
@tcard tcard mentioned this pull request Jun 8, 2016
JSONPTransport.isAvailable = function() { return true; };
ConnectionManager.httpTransports['jsonp'] = ConnectionManager.transports['jsonp'] = JSONPTransport;
JSONPTransport.isAvailable = function() { return isSupported; };
if(isSupported) {
Copy link
Member

Choose a reason for hiding this comment

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

If we do not make this change (ie we still add the jsonp member) then if anyone attempts to request jsonp they will get an error saying it isn't supported (which I think is preferable), instead of saying it's unrecognised.

Copy link
Member

Choose a reason for hiding this comment

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

I disagree, I think what's been done is correct. All other transports only add themselves to the transports array if they're supported (and connectionManager occasionally assumes that). If someone using React uses transports: ['jsonp'] (though I don't imagine anyone would), they'll get a "no requested transports available" error, same as if someone using IE8 specified transports: ['web_socket'].

Copy link
Member

Choose a reason for hiding this comment

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

I disagree, I think what's been done is correct.

Fair enough. Maybe I should go back and read my own code :(

@paddybyers
Copy link
Member

One comment but otherwise LGTM.

@SimonWoolf ?

@SimonWoolf
Copy link
Member

LGTM (though @tcard as a rule we generally don't check in generated files until we release a new version, eg so merge conflicts etc only have to be solved in one place rather than many).

I'll merge this in once the transport fallback changes have been merged in, as I'll need to rebase this on top of that (transport array names have changed).

SimonWoolf added a commit that referenced this pull request Jun 13, 2016
@SimonWoolf
Copy link
Member

Merged as 79f93f0

@SimonWoolf SimonWoolf closed this Jun 13, 2016
@mattheworiordan mattheworiordan deleted the jsonp-optional branch June 13, 2016 12:07
@mattheworiordan
Copy link
Member

👍

@mattheworiordan
Copy link
Member

@SimonWoolf mind adding something to Readme about the library supporting React Native & also Cordova?

@SimonWoolf
Copy link
Member

@mattheworiordan
Copy link
Member

Thanks @SimonWoolf

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

Successfully merging this pull request may close these issues.

4 participants