( elem, dimension, extra )
| 108 | } |
| 109 | |
| 110 | function getWidthOrHeight( elem, dimension, extra ) { |
| 111 | |
| 112 | // Start with computed style |
| 113 | var styles = getStyles( elem ), |
| 114 | |
| 115 | // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). |
| 116 | // Fake content-box until we know it's needed to know the true value. |
| 117 | boxSizingNeeded = isIE || extra, |
| 118 | isBorderBox = boxSizingNeeded && |
| 119 | jQuery.css( elem, "boxSizing", false, styles ) === "border-box", |
| 120 | valueIsBorderBox = isBorderBox, |
| 121 | |
| 122 | val = curCSS( elem, dimension, styles ), |
| 123 | offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); |
| 124 | |
| 125 | // Return a confounding non-pixel value or feign ignorance, as appropriate. |
| 126 | if ( rnumnonpx.test( val ) ) { |
| 127 | if ( !extra ) { |
| 128 | return val; |
| 129 | } |
| 130 | val = "auto"; |
| 131 | } |
| 132 | |
| 133 | |
| 134 | if ( |
| 135 | ( |
| 136 | |
| 137 | // Fall back to offsetWidth/offsetHeight when value is "auto" |
| 138 | // This happens for inline elements with no explicit setting (gh-3571) |
| 139 | val === "auto" || |
| 140 | |
| 141 | // Support: IE 9 - 11+ |
| 142 | // Use offsetWidth/offsetHeight for when box sizing is unreliable. |
| 143 | // In those cases, the computed value can be trusted to be border-box. |
| 144 | ( isIE && isBorderBox ) || |
| 145 | |
| 146 | ( !support.reliableColDimensions() && nodeName( elem, "col" ) ) || |
| 147 | |
| 148 | ( !support.reliableTrDimensions() && nodeName( elem, "tr" ) ) |
| 149 | ) && |
| 150 | |
| 151 | // Make sure the element is visible & connected |
| 152 | elem.getClientRects().length ) { |
| 153 | |
| 154 | isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; |
| 155 | |
| 156 | // Where available, offsetWidth/offsetHeight approximate border box dimensions. |
| 157 | // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the |
| 158 | // retrieved value as a content box dimension. |
| 159 | valueIsBorderBox = offsetProp in elem; |
| 160 | if ( valueIsBorderBox ) { |
| 161 | val = elem[ offsetProp ]; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // Normalize "" and auto |
| 166 | val = parseFloat( val ) || 0; |
| 167 |
no test coverage detected