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

Function getWidthOrHeight

2.1.1/test/other.js:3187–3229  ·  view source on GitHub ↗
( elem, name, extra )

Source from the content-addressed store, hash-verified

3185}
3186
3187function getWidthOrHeight( elem, name, extra ) {
3188
3189 // Start with offset property, which is equivalent to the border-box value
3190 var valueIsBorderBox = true,
3191 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
3192 styles = getStyles( elem ),
3193 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
3194
3195 // some non-html elements return undefined for offsetWidth, so check for null/undefined
3196 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
3197 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
3198 if ( val <= 0 || val == null ) {
3199 // Fall back to computed then uncomputed css if necessary
3200 val = curCSS( elem, name, styles );
3201 if ( val < 0 || val == null ) {
3202 val = elem.style[ name ];
3203 }
3204
3205 // Computed unit is not pixels. Stop here and return.
3206 if ( rnumnonpx.test(val) ) {
3207 return val;
3208 }
3209
3210 // we need the check for style in case a browser which returns unreliable values
3211 // for getComputedStyle silently falls back to the reliable elem.style
3212 valueIsBorderBox = isBorderBox &&
3213 ( support.boxSizingReliable() || val === elem.style[ name ] );
3214
3215 // Normalize "", auto, and prepare for extra
3216 val = parseFloat( val ) || 0;
3217 }
3218
3219 // use the active box-sizing model to add/subtract irrelevant styles
3220 return ( val +
3221 augmentWidthOrHeight(
3222 elem,
3223 name,
3224 extra || ( isBorderBox ? "border" : "content" ),
3225 valueIsBorderBox,
3226 styles
3227 )
3228 ) + "px";
3229}
3230
3231function showHide( elements, show ) {
3232 var display, elem, hidden,

Callers 1

other.jsFile · 0.70

Calls 3

getStylesFunction · 0.70
curCSSFunction · 0.70
augmentWidthOrHeightFunction · 0.70

Tested by

no test coverage detected