Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

jsonp httpBackend callback fix if no data sent from the server throws an error ie9 failed #3979

Closed
wants to merge 4 commits into from

Conversation

kierenhughes90
Copy link

added a default for data passed to the callback if the call of httpBackend is of type jsonp and there is null or undefined or empty string from the server to set the data to empty array - [], to avoid an error being thrown inside angular js - fixed broken test

…ckend is of type jsonp and there is null or undefined or empty string from the server to set the data to empty array - [], to avoid an error being thrown inside angular js
@mary-poppins
Copy link

Thanks for the PR!

  • Contributor signed CLA now or in the past
    • If you just signed, leave a comment here with your real name
  • PR's commit messages follow the commit message format

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@IgorMinar
Copy link
Contributor

I'm sorry, but I wasn't able to verify your CLA signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let me know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@@ -40,6 +40,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
if (lowercase(method) == 'jsonp') {
var callbackId = '_' + (callbacks.counter++).toString(36);
callbacks[callbackId] = function(data) {
data = data || [];
Copy link
Contributor

Choose a reason for hiding this comment

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

why an array? would a regular object not be more appropriate? Also, indentation

Copy link
Contributor

Choose a reason for hiding this comment

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

More importantly, this would also cause issues if the server sends null, 0 or false, which might not be very good, although one hopes that they wouldn't... should only do this if data is undefined

@caitp
Copy link
Contributor

caitp commented Jan 24, 2014

This pull-request should also fix #4987

@caitp
Copy link
Contributor

caitp commented Apr 7, 2014

@skyGoWeb I think this may have been fixed by 6680b7b, can you verify that? --- NVM, verified that the fix in 1.3 works in IE9. Unfortunately it won't work in IE8.

@caitp
Copy link
Contributor

caitp commented Apr 7, 2014

Actually, this is only fixed in 1.3, maybe I can hack my changes so it can be backported to 1.2.

@pkozlowski-opensource
Copy link
Member

@caitp if I understand you correctly we should close this PR and eventually try to back-port 6680b7b into 1.2.x, right? We could do it if people are requesting this change.

@skyGoWeb thnx for all the work on this PR but the issue seems to be solved in master already, so I'm going to close this PR. Would be totally cool if you could verify the fix / provide feedback or create back-port PR if you care about having this fixed in 1.2.x. Once again, thnx for all the effort, this is much appreciated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants