diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ajax.js | 34 | ||||
-rw-r--r-- | src/ajax/xhr.js | 2 | ||||
-rw-r--r-- | src/css.js | 46 |
3 files changed, 26 insertions, 56 deletions
diff --git a/src/ajax.js b/src/ajax.js index f0d722845..2a1076391 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -15,10 +15,6 @@ var r20 = /%20/g, rselectTextarea = /^(?:select|textarea)/i, rspacesAjax = /\s+/, rts = /([?&])_=[^&]*/, - rucHeaders = /(^|\-)([a-z])/g, - rucHeadersFunc = function( _, $1, $2 ) { - return $1 + $2.toUpperCase(); - }, rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, // Keep a copy of the old load method @@ -416,7 +412,7 @@ jQuery.extend({ // Caches the header setRequestHeader: function( name, value ) { if ( !state ) { - requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value; + requestHeaders[ name.toLowerCase() ] = { n: name, v: value }; } return this; }, @@ -664,24 +660,27 @@ jQuery.extend({ // Set the correct header, if data is being sent if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { - requestHeaders[ "Content-Type" ] = s.contentType; + jqXHR.setRequestHeader( "Content-Type", s.contentType ); } // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. if ( s.ifModified ) { ifModifiedKey = ifModifiedKey || s.url; if ( jQuery.lastModified[ ifModifiedKey ] ) { - requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ]; + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); } if ( jQuery.etag[ ifModifiedKey ] ) { - requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ]; + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); } } // Set the Accepts header for the server, depending on the dataType - requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? - s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) : - s.accepts[ "*" ]; + jqXHR.setRequestHeader( + "Accept", + s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? + s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) : + s.accepts[ "*" ] + ); // Check for headers option for ( i in s.headers ) { @@ -773,7 +772,7 @@ jQuery.extend({ }); function buildParams( prefix, obj, traditional, add ) { - if ( jQuery.isArray( obj ) && obj.length ) { + if ( jQuery.isArray( obj ) ) { // Serialize array item. jQuery.each( obj, function( i, v ) { if ( traditional || rbracket.test( prefix ) ) { @@ -793,16 +792,9 @@ function buildParams( prefix, obj, traditional, add ) { }); } else if ( !traditional && obj != null && typeof obj === "object" ) { - // If we see an array here, it is empty and should be treated as an empty - // object - if ( jQuery.isArray( obj ) || jQuery.isEmptyObject( obj ) ) { - add( prefix, "" ); - // Serialize object item. - } else { - for ( var name in obj ) { - buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); - } + for ( var name in obj ) { + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); } } else { diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js index 5dbc33d3f..ba4c3ec7e 100644 --- a/src/ajax/xhr.js +++ b/src/ajax/xhr.js @@ -104,7 +104,7 @@ if ( jQuery.support.ajax ) { // Need an extra try/catch for cross domain requests in Firefox 3 try { for ( i in headers ) { - xhr.setRequestHeader( i, headers[ i ] ); + xhr.setRequestHeader( headers[ i ].n, headers[ i ].v ); } } catch( _ ) {} diff --git a/src/css.js b/src/css.js index 9db659967..c5c01ecac 100644 --- a/src/css.js +++ b/src/css.js @@ -9,7 +9,6 @@ var ralpha = /alpha\([^)]*\)/i, rnum = /^-?\d/, rrelNum = /^[+\-]=/, rrelNumFilter = /[^+\-\.\de]+/g, - rinputbutton = /input|button/i, cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssWidth = [ "Left", "Right" ], @@ -339,45 +338,24 @@ curCSS = getComputedStyle || currentStyle; function getWH( elem, name, extra ) { var which = name === "width" ? cssWidth : cssHeight, - cur = curCSS( elem, name ), - - // We're addressing the way Firefox handles certain inputs and buttons, - // offsetWidth/height actually returns a normal width/height - boxSizing = rinputbutton.test( elem.nodeName ) && - ( curCSS( elem, "-moz-box-sizing" ) === "border-box" || - curCSS( elem, "box-sizing" ) === "border-box" ); - - // IE will return auto if we try to grab a width/height that is not set - if ( boxSizing || cur === "auto" ) { - cur = name === "width" ? elem.offsetWidth : elem.offsetHeight; - } + val = name === "width" ? elem.offsetWidth : elem.offsetHeight; - // Make sure that IE7 returns the correct computed value for display - if ( name === "height" ) { - elem.offsetHeight; + if ( extra === "border" ) { + return val; } - - var val = parseFloat( cur ) || 0; - if ( extra ) { - for ( var i = 0, len = which.length; i < len ; i++ ) { - var dir = which[i]; + jQuery.each( which, function() { + if ( !extra ) { + val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0; + } - // outerWidth/height - if ( extra === "border" || extra === "margin" ) { - val += parseFloat(jQuery.css( elem, "border" + dir + "Width" )) || 0; - val += parseFloat(jQuery.css( elem, "padding" + dir )) || 0; + if ( extra === "margin" ) { + val += parseFloat(jQuery.css( elem, "margin" + this )) || 0; - if ( extra == "margin" ) { - val += parseFloat(jQuery.css( elem, "margin" + dir )) || 0; - } - - // innerWidth/height - } else { - val += parseFloat(jQuery.css( elem, "padding" + dir )) || 0; - } + } else { + val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0; } - } + }); return val; } |