X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=39abe905940bbe760d4ba8057291912c03827ce3;hb=7c9a5e6016c2fcd38872367a891e5b3887d3df53;hp=4258b674428a68f5954fac63dc4f6bfa26134261;hpb=389c099df686bd104ce0aab3361a94ebf3a05ce6;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index 4258b67..39abe90 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -334,13 +334,17 @@ jQuery.extend({ var // Create the final options object s = jQuery.extend( true, {}, jQuery.ajaxSettings, options ), - // Callbacks contexts + // Callbacks context // We force the original context if it exists // or take it from jQuery.ajaxSettings otherwise // (plain objects used as context get extended) callbackContext = ( s.context = ( "context" in options ? options : jQuery.ajaxSettings ).context ) || s, - globalEventContext = callbackContext === s ? jQuery.event : jQuery( callbackContext ), + // Context for global events + // It's the callbackContext if one was provided in the options + // and if it's a DOM node + globalEventContext = callbackContext !== s && callbackContext.nodeType ? + jQuery( callbackContext ) : jQuery.event, // Deferreds deferred = jQuery.Deferred(), completeDeferred = jQuery._Deferred(), @@ -838,8 +842,9 @@ function ajaxConvert( s, response ) { } var dataTypes = s.dataTypes, - converters = s.converters, + converters = {}, i, + key, length = dataTypes.length, tmp, // Current and previous dataTypes @@ -856,6 +861,16 @@ function ajaxConvert( s, response ) { // For each dataType in the chain for( i = 1; i < length; i++ ) { + // Create converters map + // with lowercased keys + if ( i === 1 ) { + for( key in s.converters ) { + if( typeof key === "string" ) { + converters[ key.toLowerCase() ] = s.converters[ key ]; + } + } + } + // Get the dataTypes prev = current; current = dataTypes[ i ];