Skip to content

Commit a2f63ff

Browse files
committed
Tests: test element position outside view
Ref 49833f7 Ref gh-2828 Ref gh-2836 Fixes gh-2909
1 parent 5943f1d commit a2f63ff

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

test/data/testsuite.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,15 @@ section { background:#f0f; display:block; }
130130
.inline { display: inline; }
131131
.list-item { display: list-item; }
132132
.hidden, .none { display: none; }
133+
134+
#div-gh-2836 {
135+
position: relative;
136+
overflow: auto;
137+
height: 100px;
138+
}
139+
#div-gh-2836 div {
140+
position: relative;
141+
height: 100%;
142+
padding: 0;
143+
margin: 0;
144+
}

test/unit/dimensions.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,4 +471,34 @@ QUnit.test( "allow modification of coordinates argument (gh-1848)", function( as
471471
"coordinates are modified (got offset.top: " + offsetTop + ")" );
472472
} );
473473

474+
QUnit.test( "outside view position (gh-2836)", function( assert ) {
475+
476+
// This test ported from gh-2836 example
477+
assert.expect( 1 );
478+
479+
var parent,
480+
html = [
481+
"<div id=div-gh-2836>",
482+
"<div></div>",
483+
"<div></div>",
484+
"<div></div>",
485+
"<div></div>",
486+
"<div></div>",
487+
"</div>"
488+
].join( "" ),
489+
stop = assert.async();
490+
491+
parent = $( html );
492+
parent.appendTo( "#qunit-fixture" );
493+
494+
parent.one( "scroll", function() {
495+
var pos = parent.find( "div" ).eq( 3 ).position();
496+
497+
assert.strictEqual(pos.top, -100);
498+
stop();
499+
});
500+
501+
parent.scrollTop( 400 );
502+
} );
503+
474504
} )();

0 commit comments

Comments
 (0)