@@ -734,26 +734,32 @@ jQuery.extend({
734
734
elem . style [ name ] = old [ name ] ;
735
735
} ,
736
736
737
- css : function ( elem , name , force ) {
737
+ css : function ( elem , name , force , extra ) {
738
738
if ( name == "width" || name == "height" ) {
739
739
var val , props = { position : "absolute" , visibility : "hidden" , display :"block" } , which = name == "width" ? [ "Left" , "Right" ] : [ "Top" , "Bottom" ] ;
740
740
741
741
function getWH ( ) {
742
742
val = name == "width" ? elem . offsetWidth : elem . offsetHeight ;
743
- var padding = 0 , border = 0 ;
743
+
744
+ if ( extra === "border" )
745
+ return ;
746
+
744
747
jQuery . each ( which , function ( ) {
745
- padding += parseFloat ( jQuery . curCSS ( elem , "padding" + this , true ) ) || 0 ;
746
- border += parseFloat ( jQuery . curCSS ( elem , "border" + this + "Width" , true ) ) || 0 ;
748
+ if ( ! extra )
749
+ val -= parseFloat ( jQuery . curCSS ( elem , "padding" + this , true ) ) || 0 ;
750
+ if ( extra === "margin" )
751
+ val += parseFloat ( jQuery . curCSS ( elem , "margin" + this , true ) ) || 0 ;
752
+ else
753
+ val -= parseFloat ( jQuery . curCSS ( elem , "border" + this + "Width" , true ) ) || 0 ;
747
754
} ) ;
748
- val -= Math . round ( padding + border ) ;
749
755
}
750
756
751
- if ( jQuery ( elem ) . is ( ":visible" ) )
757
+ if ( elem . offsetWidth !== 0 )
752
758
getWH ( ) ;
753
759
else
754
760
jQuery . swap ( elem , props , getWH ) ;
755
761
756
- return Math . max ( 0 , val ) ;
762
+ return Math . max ( 0 , Math . round ( val ) ) ;
757
763
}
758
764
759
765
return jQuery . curCSS ( elem , name , force ) ;
0 commit comments