( elem, dimension, extra )
| 6773 | } |
| 6774 | |
| 6775 | function getWidthOrHeight( elem, dimension, extra ) { |
| 6776 | |
| 6777 | // Start with computed style |
| 6778 | var styles = getStyles( elem ), |
| 6779 | |
| 6780 | // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). |
| 6781 | // Fake content-box until we know it's needed to know the true value. |
| 6782 | boxSizingNeeded = !support.boxSizingReliable() || extra, |
| 6783 | isBorderBox = boxSizingNeeded && |
| 6784 | jQuery.css( elem, "boxSizing", false, styles ) === "border-box", |
| 6785 | valueIsBorderBox = isBorderBox, |
| 6786 | |
| 6787 | val = curCSS( elem, dimension, styles ), |
| 6788 | offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); |
| 6789 | |
| 6790 | // Support: Firefox <=54 |
| 6791 | // Return a confounding non-pixel value or feign ignorance, as appropriate. |
| 6792 | if ( rnumnonpx.test( val ) ) { |
| 6793 | if ( !extra ) { |
| 6794 | return val; |
| 6795 | } |
| 6796 | val = "auto"; |
| 6797 | } |
| 6798 | |
| 6799 | |
| 6800 | // Support: IE 9 - 11 only |
| 6801 | // Use offsetWidth/offsetHeight for when box sizing is unreliable. |
| 6802 | // In those cases, the computed value can be trusted to be border-box. |
| 6803 | if ( ( !support.boxSizingReliable() && isBorderBox || |
| 6804 | |
| 6805 | // Support: IE 10 - 11+, Edge 15 - 18+ |
| 6806 | // IE/Edge misreport `getComputedStyle` of table rows with width/height |
| 6807 | // set in CSS while `offset*` properties report correct values. |
| 6808 | // Interestingly, in some cases IE 9 doesn't suffer from this issue. |
| 6809 | !support.reliableTrDimensions() && nodeName( elem, "tr" ) || |
| 6810 | |
| 6811 | // Fall back to offsetWidth/offsetHeight when value is "auto" |
| 6812 | // This happens for inline elements with no explicit setting (gh-3571) |
| 6813 | val === "auto" || |
| 6814 | |
| 6815 | // Support: Android <=4.1 - 4.3 only |
| 6816 | // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) |
| 6817 | !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && |
| 6818 | |
| 6819 | // Make sure the element is visible & connected |
| 6820 | elem.getClientRects().length ) { |
| 6821 | |
| 6822 | isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; |
| 6823 | |
| 6824 | // Where available, offsetWidth/offsetHeight approximate border box dimensions. |
| 6825 | // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the |
| 6826 | // retrieved value as a content box dimension. |
| 6827 | valueIsBorderBox = offsetProp in elem; |
| 6828 | if ( valueIsBorderBox ) { |
| 6829 | val = elem[ offsetProp ]; |
| 6830 | } |
| 6831 | } |
| 6832 |
no test coverage detected