]> source.dussan.org Git - jquery.git/commitdiff
Revised conversion logic to handle converter equal to true properly.
authorjaubourg <j@ubourg.net>
Wed, 29 Dec 2010 17:44:45 +0000 (18:44 +0100)
committerjaubourg <j@ubourg.net>
Fri, 31 Dec 2010 03:15:12 +0000 (04:15 +0100)
src/ajax.js

index 0fca962aaf28e0bcc90145fd2de6bfe0e1547fc0..5e58a0fa006ab5ad858cb7e8e4a2a52717596422 100644 (file)
@@ -393,9 +393,9 @@ jQuery.extend({
                                                        current,
                                                        prev,
                                                        checker,
+                                                       conv,
                                                        conv1,
                                                        conv2,
-                                                       oneConv,
                                                        convertion,
                                                        dataTypes = s.dataTypes,
                                                        converters = s.converters,
@@ -419,23 +419,28 @@ jQuery.extend({
                                                                
                                                                if ( prev !== "*" && current !== "*" && prev !== current ) {
                                                                
-                                                                       oneConv = conv1 = 
-                                                                               converters[ ( conversion = prev + " " + current ) ] ||
+                                                                       conv = converters[ ( conversion = prev + " " + current ) ] ||
                                                                                converters[ "* " + current ];
                                                                        
-                                                                       if ( oneConv !== true ) {
-                                                                               
-                                                                               if ( ! oneConv && prev !== "text" && current !== "text" ) {
-                                                                                       conv1 = converters[ prev + " text" ] || converters[ "* text" ];
-                                                                                       conv2 = converters[ "text " + current ];
-                                                                               }
-                                                                               
-                                                                               if ( oneConv || conv1 && conv2 ) {
-                                                                                       response = oneConv ? conv1( response ) : conv2( conv1( response ) );
-                                                                               } else {
-                                                                                       throw "no " + conversion;
+                                                                       conv1 = conv2 = 0;
+                                                                       
+                                                                       if ( ! conv && prev !== "text" && current !== "text" ) {
+                                                                               conv1 = converters[ prev + " text" ] || converters[ "* text" ];
+                                                                               conv2 = converters[ "text " + current ];
+                                                                               if ( conv1 === true ) {
+                                                                                       conv = conv2;
+                                                                               } else if ( conv2 === true ) {
+                                                                                       conv = conv1;
                                                                                }
                                                                        }
+                                                                       
+                                                                       if ( ! ( conv || conv1 && conv2 ) ) {
+                                                                               throw conversion;
+                                                                       }
+                                                                       
+                                                                       if ( conv !== true ) {
+                                                                               response = conv ? conv( response ) : conv2( conv1( response ) );
+                                                                       }
                                                                }
                                                        } else if ( s.dataFilter ) {