-
Notifications
You must be signed in to change notification settings - Fork 27.4k
jsonp httpBackend callback fix if no data sent from the server throws an error ie9 failed #3979
Conversation
…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
Thanks for the PR!
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
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. |
@@ -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 || []; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
This pull-request should also fix #4987 |
@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. |
Actually, this is only fixed in 1.3, maybe I can hack my changes so it can be backported to 1.2. |
@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. |
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