MCPcopy Create free account
hub / github.com/frank-lam/fullstack-tutorial / getWidthOrHeight

Function getWidthOrHeight

notes/docsify/unpkg/gotop/jquery-2.1.0.js:5727–5769  ·  view source on GitHub ↗
( elem, name, extra )

Source from the content-addressed store, hash-verified

5725}
5726
5727function getWidthOrHeight( elem, name, extra ) {
5728
5729 // Start with offset property, which is equivalent to the border-box value
5730 var valueIsBorderBox = true,
5731 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
5732 styles = getStyles( elem ),
5733 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
5734
5735 // some non-html elements return undefined for offsetWidth, so check for null/undefined
5736 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
5737 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
5738 if ( val <= 0 || val == null ) {
5739 // Fall back to computed then uncomputed css if necessary
5740 val = curCSS( elem, name, styles );
5741 if ( val < 0 || val == null ) {
5742 val = elem.style[ name ];
5743 }
5744
5745 // Computed unit is not pixels. Stop here and return.
5746 if ( rnumnonpx.test(val) ) {
5747 return val;
5748 }
5749
5750 // we need the check for style in case a browser which returns unreliable values
5751 // for getComputedStyle silently falls back to the reliable elem.style
5752 valueIsBorderBox = isBorderBox &&
5753 ( support.boxSizingReliable() || val === elem.style[ name ] );
5754
5755 // Normalize "", auto, and prepare for extra
5756 val = parseFloat( val ) || 0;
5757 }
5758
5759 // use the active box-sizing model to add/subtract irrelevant styles
5760 return ( val +
5761 augmentWidthOrHeight(
5762 elem,
5763 name,
5764 extra || ( isBorderBox ? "border" : "content" ),
5765 valueIsBorderBox,
5766 styles
5767 )
5768 ) + "px";
5769}
5770
5771function showHide( elements, show ) {
5772 var display, elem, hidden,

Callers 1

jquery-2.1.0.jsFile · 0.85

Calls 3

getStylesFunction · 0.85
curCSSFunction · 0.85
augmentWidthOrHeightFunction · 0.85

Tested by

no test coverage detected