| @@ 9251-9345 (lines=95) @@ | ||
| 9248 | /* Chain conversions given the request and the original response |
|
| 9249 | * Also sets the responseXXX fields on the jqXHR instance |
|
| 9250 | */ |
|
| 9251 | function ajaxConvert( s, response, jqXHR, isSuccess ) { |
|
| 9252 | var conv2, current, conv, tmp, prev, |
|
| 9253 | converters = {}, |
|
| 9254 | ||
| 9255 | // Work with a copy of dataTypes in case we need to modify it for conversion |
|
| 9256 | dataTypes = s.dataTypes.slice(); |
|
| 9257 | ||
| 9258 | // Create converters map with lowercased keys |
|
| 9259 | if ( dataTypes[ 1 ] ) { |
|
| 9260 | for ( conv in s.converters ) { |
|
| 9261 | converters[ conv.toLowerCase() ] = s.converters[ conv ]; |
|
| 9262 | } |
|
| 9263 | } |
|
| 9264 | ||
| 9265 | current = dataTypes.shift(); |
|
| 9266 | ||
| 9267 | // Convert to each sequential dataType |
|
| 9268 | while ( current ) { |
|
| 9269 | ||
| 9270 | if ( s.responseFields[ current ] ) { |
|
| 9271 | jqXHR[ s.responseFields[ current ] ] = response; |
|
| 9272 | } |
|
| 9273 | ||
| 9274 | // Apply the dataFilter if provided |
|
| 9275 | if ( !prev && isSuccess && s.dataFilter ) { |
|
| 9276 | response = s.dataFilter( response, s.dataType ); |
|
| 9277 | } |
|
| 9278 | ||
| 9279 | prev = current; |
|
| 9280 | current = dataTypes.shift(); |
|
| 9281 | ||
| 9282 | if ( current ) { |
|
| 9283 | ||
| 9284 | // There's only work to do if current dataType is non-auto |
|
| 9285 | if ( current === "*" ) { |
|
| 9286 | ||
| 9287 | current = prev; |
|
| 9288 | ||
| 9289 | // Convert response if prev dataType is non-auto and differs from current |
|
| 9290 | } else if ( prev !== "*" && prev !== current ) { |
|
| 9291 | ||
| 9292 | // Seek a direct converter |
|
| 9293 | conv = converters[ prev + " " + current ] || converters[ "* " + current ]; |
|
| 9294 | ||
| 9295 | // If none found, seek a pair |
|
| 9296 | if ( !conv ) { |
|
| 9297 | for ( conv2 in converters ) { |
|
| 9298 | ||
| 9299 | // If conv2 outputs current |
|
| 9300 | tmp = conv2.split( " " ); |
|
| 9301 | if ( tmp[ 1 ] === current ) { |
|
| 9302 | ||
| 9303 | // If prev can be converted to accepted input |
|
| 9304 | conv = converters[ prev + " " + tmp[ 0 ] ] || |
|
| 9305 | converters[ "* " + tmp[ 0 ] ]; |
|
| 9306 | if ( conv ) { |
|
| 9307 | ||
| 9308 | // Condense equivalence converters |
|
| 9309 | if ( conv === true ) { |
|
| 9310 | conv = converters[ conv2 ]; |
|
| 9311 | ||
| 9312 | // Otherwise, insert the intermediate dataType |
|
| 9313 | } else if ( converters[ conv2 ] !== true ) { |
|
| 9314 | current = tmp[ 0 ]; |
|
| 9315 | dataTypes.unshift( tmp[ 1 ] ); |
|
| 9316 | } |
|
| 9317 | break; |
|
| 9318 | } |
|
| 9319 | } |
|
| 9320 | } |
|
| 9321 | } |
|
| 9322 | ||
| 9323 | // Apply converter (if not an equivalence) |
|
| 9324 | if ( conv !== true ) { |
|
| 9325 | ||
| 9326 | // Unless errors are allowed to bubble, catch and return them |
|
| 9327 | if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation |
|
| 9328 | response = conv( response ); |
|
| 9329 | } else { |
|
| 9330 | try { |
|
| 9331 | response = conv( response ); |
|
| 9332 | } catch ( e ) { |
|
| 9333 | return { |
|
| 9334 | state: "parsererror", |
|
| 9335 | error: conv ? e : "No conversion from " + prev + " to " + current |
|
| 9336 | }; |
|
| 9337 | } |
|
| 9338 | } |
|
| 9339 | } |
|
| 9340 | } |
|
| 9341 | } |
|
| 9342 | } |
|
| 9343 | ||
| 9344 | return { state: "success", data: response }; |
|
| 9345 | } |
|
| 9346 | ||
| 9347 | jQuery.extend( { |
|
| 9348 | ||
| @@ 8166-8260 (lines=95) @@ | ||
| 8163 | /* Chain conversions given the request and the original response |
|
| 8164 | * Also sets the responseXXX fields on the jqXHR instance |
|
| 8165 | */ |
|
| 8166 | function ajaxConvert( s, response, jqXHR, isSuccess ) { |
|
| 8167 | var conv2, current, conv, tmp, prev, |
|
| 8168 | converters = {}, |
|
| 8169 | ||
| 8170 | // Work with a copy of dataTypes in case we need to modify it for conversion |
|
| 8171 | dataTypes = s.dataTypes.slice(); |
|
| 8172 | ||
| 8173 | // Create converters map with lowercased keys |
|
| 8174 | if ( dataTypes[ 1 ] ) { |
|
| 8175 | for ( conv in s.converters ) { |
|
| 8176 | converters[ conv.toLowerCase() ] = s.converters[ conv ]; |
|
| 8177 | } |
|
| 8178 | } |
|
| 8179 | ||
| 8180 | current = dataTypes.shift(); |
|
| 8181 | ||
| 8182 | // Convert to each sequential dataType |
|
| 8183 | while ( current ) { |
|
| 8184 | ||
| 8185 | if ( s.responseFields[ current ] ) { |
|
| 8186 | jqXHR[ s.responseFields[ current ] ] = response; |
|
| 8187 | } |
|
| 8188 | ||
| 8189 | // Apply the dataFilter if provided |
|
| 8190 | if ( !prev && isSuccess && s.dataFilter ) { |
|
| 8191 | response = s.dataFilter( response, s.dataType ); |
|
| 8192 | } |
|
| 8193 | ||
| 8194 | prev = current; |
|
| 8195 | current = dataTypes.shift(); |
|
| 8196 | ||
| 8197 | if ( current ) { |
|
| 8198 | ||
| 8199 | // There's only work to do if current dataType is non-auto |
|
| 8200 | if ( current === "*" ) { |
|
| 8201 | ||
| 8202 | current = prev; |
|
| 8203 | ||
| 8204 | // Convert response if prev dataType is non-auto and differs from current |
|
| 8205 | } else if ( prev !== "*" && prev !== current ) { |
|
| 8206 | ||
| 8207 | // Seek a direct converter |
|
| 8208 | conv = converters[ prev + " " + current ] || converters[ "* " + current ]; |
|
| 8209 | ||
| 8210 | // If none found, seek a pair |
|
| 8211 | if ( !conv ) { |
|
| 8212 | for ( conv2 in converters ) { |
|
| 8213 | ||
| 8214 | // If conv2 outputs current |
|
| 8215 | tmp = conv2.split( " " ); |
|
| 8216 | if ( tmp[ 1 ] === current ) { |
|
| 8217 | ||
| 8218 | // If prev can be converted to accepted input |
|
| 8219 | conv = converters[ prev + " " + tmp[ 0 ] ] || |
|
| 8220 | converters[ "* " + tmp[ 0 ] ]; |
|
| 8221 | if ( conv ) { |
|
| 8222 | ||
| 8223 | // Condense equivalence converters |
|
| 8224 | if ( conv === true ) { |
|
| 8225 | conv = converters[ conv2 ]; |
|
| 8226 | ||
| 8227 | // Otherwise, insert the intermediate dataType |
|
| 8228 | } else if ( converters[ conv2 ] !== true ) { |
|
| 8229 | current = tmp[ 0 ]; |
|
| 8230 | dataTypes.unshift( tmp[ 1 ] ); |
|
| 8231 | } |
|
| 8232 | break; |
|
| 8233 | } |
|
| 8234 | } |
|
| 8235 | } |
|
| 8236 | } |
|
| 8237 | ||
| 8238 | // Apply converter (if not an equivalence) |
|
| 8239 | if ( conv !== true ) { |
|
| 8240 | ||
| 8241 | // Unless errors are allowed to bubble, catch and return them |
|
| 8242 | if ( conv && s.throws ) { |
|
| 8243 | response = conv( response ); |
|
| 8244 | } else { |
|
| 8245 | try { |
|
| 8246 | response = conv( response ); |
|
| 8247 | } catch ( e ) { |
|
| 8248 | return { |
|
| 8249 | state: "parsererror", |
|
| 8250 | error: conv ? e : "No conversion from " + prev + " to " + current |
|
| 8251 | }; |
|
| 8252 | } |
|
| 8253 | } |
|
| 8254 | } |
|
| 8255 | } |
|
| 8256 | } |
|
| 8257 | } |
|
| 8258 | ||
| 8259 | return { state: "success", data: response }; |
|
| 8260 | } |
|
| 8261 | ||
| 8262 | jQuery.extend( { |
|
| 8263 | ||
| @@ 7708-7797 (lines=90) @@ | ||
| 7705 | /* Chain conversions given the request and the original response |
|
| 7706 | * Also sets the responseXXX fields on the jqXHR instance |
|
| 7707 | */ |
|
| 7708 | function ajaxConvert( s, response, jqXHR, isSuccess ) { |
|
| 7709 | var conv2, current, conv, tmp, prev, |
|
| 7710 | converters = {}, |
|
| 7711 | // Work with a copy of dataTypes in case we need to modify it for conversion |
|
| 7712 | dataTypes = s.dataTypes.slice(); |
|
| 7713 | ||
| 7714 | // Create converters map with lowercased keys |
|
| 7715 | if ( dataTypes[ 1 ] ) { |
|
| 7716 | for ( conv in s.converters ) { |
|
| 7717 | converters[ conv.toLowerCase() ] = s.converters[ conv ]; |
|
| 7718 | } |
|
| 7719 | } |
|
| 7720 | ||
| 7721 | current = dataTypes.shift(); |
|
| 7722 | ||
| 7723 | // Convert to each sequential dataType |
|
| 7724 | while ( current ) { |
|
| 7725 | ||
| 7726 | if ( s.responseFields[ current ] ) { |
|
| 7727 | jqXHR[ s.responseFields[ current ] ] = response; |
|
| 7728 | } |
|
| 7729 | ||
| 7730 | // Apply the dataFilter if provided |
|
| 7731 | if ( !prev && isSuccess && s.dataFilter ) { |
|
| 7732 | response = s.dataFilter( response, s.dataType ); |
|
| 7733 | } |
|
| 7734 | ||
| 7735 | prev = current; |
|
| 7736 | current = dataTypes.shift(); |
|
| 7737 | ||
| 7738 | if ( current ) { |
|
| 7739 | ||
| 7740 | // There's only work to do if current dataType is non-auto |
|
| 7741 | if ( current === "*" ) { |
|
| 7742 | ||
| 7743 | current = prev; |
|
| 7744 | ||
| 7745 | // Convert response if prev dataType is non-auto and differs from current |
|
| 7746 | } else if ( prev !== "*" && prev !== current ) { |
|
| 7747 | ||
| 7748 | // Seek a direct converter |
|
| 7749 | conv = converters[ prev + " " + current ] || converters[ "* " + current ]; |
|
| 7750 | ||
| 7751 | // If none found, seek a pair |
|
| 7752 | if ( !conv ) { |
|
| 7753 | for ( conv2 in converters ) { |
|
| 7754 | ||
| 7755 | // If conv2 outputs current |
|
| 7756 | tmp = conv2.split( " " ); |
|
| 7757 | if ( tmp[ 1 ] === current ) { |
|
| 7758 | ||
| 7759 | // If prev can be converted to accepted input |
|
| 7760 | conv = converters[ prev + " " + tmp[ 0 ] ] || |
|
| 7761 | converters[ "* " + tmp[ 0 ] ]; |
|
| 7762 | if ( conv ) { |
|
| 7763 | // Condense equivalence converters |
|
| 7764 | if ( conv === true ) { |
|
| 7765 | conv = converters[ conv2 ]; |
|
| 7766 | ||
| 7767 | // Otherwise, insert the intermediate dataType |
|
| 7768 | } else if ( converters[ conv2 ] !== true ) { |
|
| 7769 | current = tmp[ 0 ]; |
|
| 7770 | dataTypes.unshift( tmp[ 1 ] ); |
|
| 7771 | } |
|
| 7772 | break; |
|
| 7773 | } |
|
| 7774 | } |
|
| 7775 | } |
|
| 7776 | } |
|
| 7777 | ||
| 7778 | // Apply converter (if not an equivalence) |
|
| 7779 | if ( conv !== true ) { |
|
| 7780 | ||
| 7781 | // Unless errors are allowed to bubble, catch and return them |
|
| 7782 | if ( conv && s[ "throws" ] ) { |
|
| 7783 | response = conv( response ); |
|
| 7784 | } else { |
|
| 7785 | try { |
|
| 7786 | response = conv( response ); |
|
| 7787 | } catch ( e ) { |
|
| 7788 | return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; |
|
| 7789 | } |
|
| 7790 | } |
|
| 7791 | } |
|
| 7792 | } |
|
| 7793 | } |
|
| 7794 | } |
|
| 7795 | ||
| 7796 | return { state: "success", data: response }; |
|
| 7797 | } |
|
| 7798 | ||
| 7799 | jQuery.extend({ |
|
| 7800 | ||