aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-04-04 16:00:55 +0200
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-04-04 16:03:06 +0200
commit7bb48a0290a20594ea2a5a7b5772e0410a67164c (patch)
tree79e93f3278d876abce331db41cb9fce2cfe7611d /test
parent9ab26aa508c6cca6afa9c6247ee6d50eaed2da77 (diff)
downloadjquery-7bb48a0290a20594ea2a5a7b5772e0410a67164c.tar.gz
jquery-7bb48a0290a20594ea2a5a7b5772e0410a67164c.zip
CSS: Make `offsetHeight( true )`, etc. include negative margins
This regressed in gh-3656 as the added logic to include scroll gutters in `.innerWidth()` / `.innerHeight()` didn't take negative margins into account. This broke handling of negative margins in `.offsetHeight( true )` and `.offsetWidth( true )`. To fix it, calculate margin delta separately and only add it after the scroll gutter adjustment logic. Fixes gh-3982 Closes gh-5234 Ref gh-3656 (cherry picked from commit bce13b72c1753e16cc0db53ebf0f0456bdcf6b48)
Diffstat (limited to 'test')
-rw-r--r--test/unit/dimensions.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js
index e5ffbb57a..dc7e719fb 100644
--- a/test/unit/dimensions.js
+++ b/test/unit/dimensions.js
@@ -240,7 +240,7 @@ QUnit.test( "outerWidth()", function( assert ) {
} );
QUnit.test( "outerHeight()", function( assert ) {
- assert.expect( 12 );
+ assert.expect( 14 );
var $div, div,
$win = jQuery( window ),
@@ -268,6 +268,11 @@ QUnit.test( "outerHeight()", function( assert ) {
$div.css( "display", "none" );
assert.equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" );
+ $div.css( "display", "" );
+ $div.css( "margin", "-10px" );
+ assert.equal( $div.outerHeight(), 74, "Test with padding, border and negative margin without margin option" );
+ assert.equal( $div.outerHeight( true ), 54, "Test with padding, border and negative margin with margin option" );
+
// reset styles
$div.css( { "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" } );