MCPcopy Index your code
hub / github.com/JsAaron/jQuery / getWH

Function getWH

1.7/css.js:329–374  ·  view source on GitHub ↗
( elem, name, extra )

Source from the content-addressed store, hash-verified

327curCSS = getComputedStyle || currentStyle;
328
329function getWH( elem, name, extra ) {
330
331 // Start with offset property
332 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
333 which = name === "width" ? cssWidth : cssHeight;
334
335 if ( val > 0 ) {
336 if ( extra !== "border" ) {
337 jQuery.each( which, function() {
338 if ( !extra ) {
339 val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
340 }
341 if ( extra === "margin" ) {
342 val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
343 } else {
344 val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
345 }
346 });
347 }
348
349 return val + "px";
350 }
351
352 // Fall back to computed then uncomputed css if necessary
353 val = curCSS( elem, name, name );
354 if ( val < 0 || val == null ) {
355 val = elem.style[ name ] || 0;
356 }
357 // Normalize "", auto, and prepare for extra
358 val = parseFloat( val ) || 0;
359
360 // Add padding, border, margin
361 if ( extra ) {
362 jQuery.each( which, function() {
363 val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
364 if ( extra !== "padding" ) {
365 val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
366 }
367 if ( extra === "margin" ) {
368 val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
369 }
370 });
371 }
372
373 return val + "px";
374}
375
376if ( jQuery.expr && jQuery.expr.filters ) {
377 jQuery.expr.filters.hidden = function( elem ) {

Callers 1

css.jsFile · 0.70

Calls 1

curCSSFunction · 0.50

Tested by

no test coverage detected