]> source.dussan.org Git - jquery.git/commitdiff
Tests: test element position outside view
authorOleg Gaidarenko <markelog@gmail.com>
Thu, 11 Feb 2016 19:31:49 +0000 (22:31 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Thu, 11 Feb 2016 19:55:34 +0000 (22:55 +0300)
Ref ee0f61647cb93d587764280b1278807d9ff86fc9
Ref gh-2828
Ref gh-2836
Fixes gh-2909

test/data/testsuite.css
test/unit/dimensions.js

index cf2ba8c205b1eba22849c402cbac2c4030f8f801..3dbf834fdaed2ed8b94fbda16eccc55f76445cad 100644 (file)
@@ -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;
+}
index 44a7291130460ad71041f6f721c5ec360c4e22b6..af269de90e2dbd215d04f7fde8aac695a9b07ae8 100644 (file)
@@ -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 = [
+               "<div id=div-gh-2836>",
+                       "<div></div>",
+                       "<div></div>",
+                       "<div></div>",
+                       "<div></div>",
+                       "<div></div>",
+               "</div>"
+       ].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 );
+} );
+
 } )();