small refactoring

This commit is contained in:
Leo Horie 2014-09-01 10:42:15 -04:00
parent 4d79d91c57
commit a87e2a1414
2 changed files with 25 additions and 51 deletions

View file

@ -887,10 +887,9 @@ Mithril = m = new function app(window, undefined) {
m.request = function(xhrOptions) {
if (xhrOptions.background !== true) m.startComputation()
var deferred = m.deferred()
var serialize = xhrOptions.serialize = xhrOptions.dataType && xhrOptions.dataType.toLowerCase() === "jsonp"
? identity : xhrOptions.serialize || JSON.stringify
var deserialize = xhrOptions.deserialize = xhrOptions.dataType && xhrOptions.dataType.toLowerCase() === "jsonp"
? identity : xhrOptions.deserialize || JSON.parse
var isJSONP = xhrOptions.dataType && xhrOptions.dataType.toLowerCase() === "jsonp"
var serialize = xhrOptions.serialize = isJSONP ? identity : xhrOptions.serialize || JSON.stringify
var deserialize = xhrOptions.deserialize = isJSONP ? identity : xhrOptions.deserialize || JSON.parse
var extract = xhrOptions.extract || function(xhr) {
return xhr.responseText.length === 0 && deserialize === JSON.parse ? null : xhr.responseText
}