MCPcopy Create free account
hub / github.com/JsAaron/jQuery / getWidthOrHeight

Function getWidthOrHeight

2.1.1/test/jquery-2.1.1.js:5780–5822  ·  view source on GitHub ↗
( elem, name, extra )

Source from the content-addressed store, hash-verified

5778}
5779
5780function getWidthOrHeight( elem, name, extra ) {
5781
5782 // Start with offset property, which is equivalent to the border-box value
5783 var valueIsBorderBox = true,
5784 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
5785 styles = getStyles( elem ),
5786 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
5787
5788 // some non-html elements return undefined for offsetWidth, so check for null/undefined
5789 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
5790 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
5791 if ( val <= 0 || val == null ) {
5792 // Fall back to computed then uncomputed css if necessary
5793 val = curCSS( elem, name, styles );
5794 if ( val < 0 || val == null ) {
5795 val = elem.style[ name ];
5796 }
5797
5798 // Computed unit is not pixels. Stop here and return.
5799 if ( rnumnonpx.test(val) ) {
5800 return val;
5801 }
5802
5803 // we need the check for style in case a browser which returns unreliable values
5804 // for getComputedStyle silently falls back to the reliable elem.style
5805 valueIsBorderBox = isBorderBox &&
5806 ( support.boxSizingReliable() || val === elem.style[ name ] );
5807
5808 // Normalize "", auto, and prepare for extra
5809 val = parseFloat( val ) || 0;
5810 }
5811
5812 // use the active box-sizing model to add/subtract irrelevant styles
5813 return ( val +
5814 augmentWidthOrHeight(
5815 elem,
5816 name,
5817 extra || ( isBorderBox ? "border" : "content" ),
5818 valueIsBorderBox,
5819 styles
5820 )
5821 ) + "px";
5822}
5823
5824function showHide( elements, show ) {
5825 var display, elem, hidden,

Callers 1

jquery-2.1.1.jsFile · 0.70

Calls 3

getStylesFunction · 0.70
curCSSFunction · 0.70
augmentWidthOrHeightFunction · 0.70

Tested by

no test coverage detected