(elem, name, extra)
| 382 | } |
| 383 | |
| 384 | function getWidthOrHeight(elem, name, extra) { |
| 385 | |
| 386 | // Start with offset property, which is equivalent to the border-box value |
| 387 | var valueIsBorderBox = true, |
| 388 | val = name === "width" ? elem.offsetWidth : elem.offsetHeight, |
| 389 | styles = getStyles(elem), |
| 390 | isBorderBox = jQuery.support.boxSizing && jQuery.css(elem, "boxSizing", false, styles) === "border-box"; |
| 391 | |
| 392 | // some non-html elements return undefined for offsetWidth, so check for null/undefined |
| 393 | // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 |
| 394 | // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 |
| 395 | if (val <= 0 || val == null) { |
| 396 | // Fall back to computed then uncomputed css if necessary |
| 397 | val = curCSS(elem, name, styles); |
| 398 | if (val < 0 || val == null) { |
| 399 | val = elem.style[name]; |
| 400 | } |
| 401 | |
| 402 | // Computed unit is not pixels. Stop here and return. |
| 403 | if (rnumnonpx.test(val)) { |
| 404 | return val; |
| 405 | } |
| 406 | |
| 407 | // we need the check for style in case a browser which returns unreliable values |
| 408 | // for getComputedStyle silently falls back to the reliable elem.style |
| 409 | valueIsBorderBox = isBorderBox && (jQuery.support.boxSizingReliable || val === elem.style[name]); |
| 410 | |
| 411 | // Normalize "", auto, and prepare for extra |
| 412 | val = parseFloat(val) || 0; |
| 413 | } |
| 414 | |
| 415 | // use the active box-sizing model to add/subtract irrelevant styles |
| 416 | return (val + |
| 417 | augmentWidthOrHeight( |
| 418 | elem, |
| 419 | name, |
| 420 | extra || (isBorderBox ? "border" : "content"), |
| 421 | valueIsBorderBox, |
| 422 | styles |
| 423 | ) |
| 424 | ) + "px"; |
| 425 | } |
| 426 | |
| 427 | // Try to determine the default display value of an element |
| 428 |
no test coverage detected