MCPcopy Create free account
hub / github.com/TruthHun/BookStack / getWidthOrHeight

Function getWidthOrHeight

static/jquery/1.12.4/jquery.js:6991–7035  ·  view source on GitHub ↗
( elem, name, extra )

Source from the content-addressed store, hash-verified

6989}
6990
6991function getWidthOrHeight( elem, name, extra ) {
6992
6993 // Start with offset property, which is equivalent to the border-box value
6994 var valueIsBorderBox = true,
6995 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6996 styles = getStyles( elem ),
6997 isBorderBox = support.boxSizing &&
6998 jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
6999
7000 // some non-html elements return undefined for offsetWidth, so check for null/undefined
7001 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
7002 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
7003 if ( val <= 0 || val == null ) {
7004
7005 // Fall back to computed then uncomputed css if necessary
7006 val = curCSS( elem, name, styles );
7007 if ( val < 0 || val == null ) {
7008 val = elem.style[ name ];
7009 }
7010
7011 // Computed unit is not pixels. Stop here and return.
7012 if ( rnumnonpx.test( val ) ) {
7013 return val;
7014 }
7015
7016 // we need the check for style in case a browser which returns unreliable values
7017 // for getComputedStyle silently falls back to the reliable elem.style
7018 valueIsBorderBox = isBorderBox &&
7019 ( support.boxSizingReliable() || val === elem.style[ name ] );
7020
7021 // Normalize "", auto, and prepare for extra
7022 val = parseFloat( val ) || 0;
7023 }
7024
7025 // use the active box-sizing model to add/subtract irrelevant styles
7026 return ( val +
7027 augmentWidthOrHeight(
7028 elem,
7029 name,
7030 extra || ( isBorderBox ? "border" : "content" ),
7031 valueIsBorderBox,
7032 styles
7033 )
7034 ) + "px";
7035}
7036
7037jQuery.extend( {
7038

Callers 1

jquery.jsFile · 0.70

Calls 3

getStylesFunction · 0.85
curCSSFunction · 0.85
augmentWidthOrHeightFunction · 0.70

Tested by

no test coverage detected