From: Oleg Gaidarenko Date: Thu, 11 Feb 2016 19:31:49 +0000 (+0300) Subject: Tests: test element position outside view X-Git-Tag: 2.2.1~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=30202be6e1730d46eec1966e2d78db7860935df9;p=jquery.git Tests: test element position outside view Ref ee0f61647cb93d587764280b1278807d9ff86fc9 Ref gh-2828 Ref gh-2836 Fixes gh-2909 --- diff --git a/test/data/testsuite.css b/test/data/testsuite.css index cf2ba8c20..3dbf834fd 100644 --- a/test/data/testsuite.css +++ b/test/data/testsuite.css @@ -142,3 +142,15 @@ section { background:#f0f; display:block; } #span-14824 { display: block; } #display { display: list-item !important; } + +#div-gh-2836 { + position: relative; + overflow: auto; + height: 100px; +} +#div-gh-2836 div { + position: relative; + height: 100%; + padding: 0; + margin: 0; +} diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index 44a729113..af269de90 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -473,4 +473,34 @@ QUnit.test( "allow modification of coordinates argument (gh-1848)", function( as "coordinates are modified (got offset.top: " + offsetTop + ")" ); } ); +QUnit.test( "outside view position (gh-2836)", function( assert ) { + + // This test ported from gh-2836 example + assert.expect( 1 ); + + var parent, + html = [ + "
", + "
", + "
", + "
", + "
", + "
", + "
" + ].join( "" ), + stop = assert.async(); + + parent = $( html ); + parent.appendTo( "#qunit-fixture" ); + + parent.one( "scroll", function() { + var pos = parent.find( "div" ).eq( 3 ).position(); + + assert.strictEqual(pos.top, -100); + stop(); + }); + + parent.scrollTop( 400 ); +} ); + } )();