Browse Source

Fixes #3653, refactors several lines to use expectsJSON

pull/3792/head
Jack Lukic 8 years ago
parent
commit
0fa338409c
2 changed files with 10 additions and 4 deletions
  1. 3
      RELEASE-NOTES.md
  2. 11
      src/definitions/behaviors/api.js

3
RELEASE-NOTES.md

@ -17,7 +17,8 @@
-**Divider** - Fixed issue where descenders like "g" would be cut off in `horizontal divider` #3585
**Bugs**
**Grid** - Fixed issue where `centered` content would cause `justified` content to appear aligned left. #3496
- **API** - Fixed bug where using `onResponse` with `dataType` other than JSON or JSONP would cause an error. (Not allowing plain text responses to be translated) #3653
- **Grid** - Fixed issue where `centered` content would cause `justified` content to appear aligned left. #3496
- **Button** - Fixes issue where `right icon` like `right arrow icon` would have additional margin inside an `icon button` #3525
- **Checkbox** - Fixed a chrome issue where radio buttons may receive `indeterminate` styles when user has not yet interacted with the page
- **Dropdown** - Fixed issue where `apiSettings` was not defaulting to use `cache: 'local'` as specified in the docs

11
src/definitions/behaviors/api.js

@ -275,6 +275,9 @@ $.api = $.fn.api = function(parameters) {
disabled: function() {
return ($module.filter(selector.disabled).length > 0);
},
expectingJSON: function() {
return settings.dataType !== 'json' && settings.dataType !== 'jsonp';
},
form: function() {
return $module.is('form') || $context.is('form');
},
@ -298,7 +301,7 @@ $.api = $.fn.api = function(parameters) {
}
},
validResponse: function(response) {
if( (settings.dataType !== 'json' && settings.dataType !== 'jsonp') || !$.isFunction(settings.successTest) ) {
if( (!module.is.expectingJSON()) || !$.isFunction(settings.successTest) ) {
module.verbose('Response is not JSON, skipping validation', settings.successTest, response);
return true;
}
@ -468,7 +471,9 @@ $.api = $.fn.api = function(parameters) {
elapsedTime = (new Date().getTime() - requestStartTime),
timeLeft = (settings.loadingDuration - elapsedTime),
translatedResponse = ( $.isFunction(settings.onResponse) )
? settings.onResponse.call(context, $.extend(true, {}, response))
? module.is.expectingJSON()
? settings.onResponse.call(context, $.extend(true, {}, response))
: settings.onResponse.call(conetxt, response)
: false
;
timeLeft = (timeLeft > 0)
@ -677,7 +682,7 @@ $.api = $.fn.api = function(parameters) {
get: {
responseFromXHR: function(xhr) {
return $.isPlainObject(xhr)
? (settings.dataType == 'json' || settings.dataType == 'jsonp')
? (module.is.expectingJSON())
? module.decode.json(xhr.responseText)
: xhr.responseText
: false

Loading…
Cancel
Save