@@ -2,6 +2,9 @@ var curCSS, iframe, iframeDoc,
2
2
ralpha = / a l p h a \( [ ^ ) ] * \) / i,
3
3
ropacity = / o p a c i t y = ( [ ^ ) ] * ) / ,
4
4
rposition = / ^ ( t o p | r i g h t | b o t t o m | l e f t ) $ / ,
5
+ // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6
+ // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
7
+ rdisplayswap = / ^ ( n o n e | t a b l e (? ! - c [ e a ] ) .+ ) / ,
5
8
rmargin = / ^ m a r g i n / ,
6
9
rnumsplit = new RegExp ( "^(" + core_pnum + ")(.*)$" , "i" ) ,
7
10
rnumnonpx = new RegExp ( "^(" + core_pnum + ")(?!px)[a-z%]+$" , "i" ) ,
@@ -493,12 +496,14 @@ jQuery.each([ "height", "width" ], function( i, name ) {
493
496
jQuery . cssHooks [ name ] = {
494
497
get : function ( elem , computed , extra ) {
495
498
if ( computed ) {
496
- if ( elem . offsetWidth !== 0 || curCSS ( elem , "display" ) !== "none" ) {
497
- return getWidthOrHeight ( elem , name , extra ) ;
498
- } else {
499
+ // certain elements can have dimension info if we invisibly show them
500
+ // however, it must have a current display style that would benefit from this
501
+ if ( elem . offsetWidth === 0 && rdisplayswap . test ( curCSS ( elem , "display" ) ) ) {
499
502
return jQuery . swap ( elem , cssShow , function ( ) {
500
503
return getWidthOrHeight ( elem , name , extra ) ;
501
504
} ) ;
505
+ } else {
506
+ return getWidthOrHeight ( elem , name , extra ) ;
502
507
}
503
508
}
504
509
} ,
0 commit comments