mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Landing pull request 413. Move border/padding checks to after width validation to avoid unnecessary fallbacks. Fixes #9598.
More Details: - https://github.com/jquery/jquery/pull/413 - http://bugs.jquery.com/ticket/9300 - http://bugs.jquery.com/ticket/9441 - http://bugs.jquery.com/ticket/9598
This commit is contained in:
parent
d59b0f3e27
commit
124817e668
21
src/css.js
21
src/css.js
@ -315,21 +315,20 @@ function getWH( elem, name, extra ) {
|
|||||||
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
||||||
which = name === "width" ? cssWidth : cssHeight;
|
which = name === "width" ? cssWidth : cssHeight;
|
||||||
|
|
||||||
if ( extra !== "margin" && extra !== "border" ) {
|
|
||||||
jQuery.each( which, function() {
|
|
||||||
val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
|
|
||||||
if ( !extra ) {
|
|
||||||
val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( val > 0 ) {
|
if ( val > 0 ) {
|
||||||
if ( extra === "margin" ) {
|
if ( extra !== "border" ) {
|
||||||
jQuery.each( which, function() {
|
jQuery.each( which, function() {
|
||||||
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
|
if ( !extra ) {
|
||||||
|
val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
|
||||||
|
}
|
||||||
|
if ( extra === "margin" ) {
|
||||||
|
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
|
||||||
|
} else {
|
||||||
|
val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return val + "px";
|
return val + "px";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user