Skip to content

Commit c3b1d9c

Browse files
committed
Tests: test element position outside view
Ref a0f5c35 Ref jquerygh-2828 Ref jquerygh-2836 Fixes jquerygh-2909
1 parent a0f5c35 commit c3b1d9c

File tree

2 files changed

+84
-42
lines changed

2 files changed

+84
-42
lines changed

test/data/testsuite.css

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,127 @@
11
/* for testing opacity set in styles in IE */
22
ol#empty {
3-
opacity: 0;
4-
filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff');
3+
opacity: 0;
4+
filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff');
55
}
66

77
div#fx-tests h4 {
8-
background: red;
8+
background: red;
99
}
1010

1111
div#fx-tests h4.pass {
12-
background: green;
12+
background: green;
1313
}
1414

1515
div#fx-tests div.box {
16-
background: red;
17-
overflow: hidden;
18-
border: 2px solid #000;
16+
background: red;
17+
overflow: hidden;
18+
border: 2px solid #000;
1919
}
2020

2121
div#fx-tests div.overflow {
22-
overflow: visible;
22+
overflow: visible;
2323
}
2424

2525
div.inline {
26-
display: inline;
26+
display: inline;
2727
}
2828

2929
div.autoheight {
30-
height: auto;
30+
height: auto;
3131
}
3232

3333
div.autowidth {
34-
width: auto;
34+
width: auto;
3535
}
3636

3737
div.autoopacity {
38-
opacity: auto;
38+
opacity: auto;
3939
}
4040

4141
div.largewidth {
42-
width: 100px;
42+
width: 100px;
4343
}
4444

4545
div.largeheight {
46-
height: 100px;
46+
height: 100px;
4747
}
4848

4949
div.largeopacity {
50-
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
50+
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
5151
}
5252

5353
div.medwidth {
54-
width: 50px;
54+
width: 50px;
5555
}
5656

5757
div.medheight {
58-
height: 50px;
58+
height: 50px;
5959
}
6060

6161
div.medopacity {
62-
opacity: 0.5;
63-
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
62+
opacity: 0.5;
63+
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
6464
}
6565

6666
div.nowidth {
67-
width: 0px;
67+
width: 0px;
6868
}
6969

7070
div.noheight {
71-
height: 0px;
71+
height: 0px;
7272
}
7373

7474
div.noopacity {
75-
opacity: 0;
76-
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
75+
opacity: 0;
76+
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
7777
}
7878

7979
div.hidden {
80-
display: none;
80+
display: none;
8181
}
8282

8383
div#fx-tests div.widewidth {
84-
background-repeat: repeat-x;
84+
background-repeat: repeat-x;
8585
}
8686

8787
div#fx-tests div.wideheight {
88-
background-repeat: repeat-y;
88+
background-repeat: repeat-y;
8989
}
9090

9191
div#fx-tests div.widewidth.wideheight {
92-
background-repeat: repeat;
92+
background-repeat: repeat;
9393
}
9494

9595
div#fx-tests div.noback {
96-
background-image: none;
96+
background-image: none;
9797
}
9898

9999
.chain-test,
100100
.chain-test div {
101-
width: 100px;
102-
height: 20px;
103-
position: relative;
104-
float: left;
101+
width: 100px;
102+
height: 20px;
103+
position: relative;
104+
float: left;
105105
}
106106
.chain-test div {
107-
position: absolute;
108-
top: 0;
109-
left: 0;
107+
position: absolute;
108+
top: 0;
109+
left: 0;
110110
}
111111

112112
.chain-test {
113-
background: red;
113+
background: red;
114114
}
115115
.chain-test div {
116-
background: green;
116+
background: green;
117117
}
118118

119119
.chain-test-out {
120-
background: green;
120+
background: green;
121121
}
122122
.chain-test-out div {
123-
background: red;
124-
display: none;
123+
background: red;
124+
display: none;
125125
}
126126

127127
/* tests to ensure jQuery can determine the native display mode of elements
@@ -159,7 +159,19 @@ section { background:#f0f; display:block; }
159159

160160
/* fix get alpha opacity in IE8 */
161161
.fix-get-alpha-opacity-in-ie8 {
162-
opacity: 0.5;
163-
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
162+
opacity: 0.5;
163+
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
164+
}
165+
166+
#div-gh-2836 {
167+
position: relative;
168+
overflow: auto;
169+
height: 100px;
170+
}
171+
#div-gh-2836 div {
172+
position: relative;
173+
height: 100%;
174+
padding: 0;
175+
margin: 0;
164176
}
165177

test/unit/dimensions.js

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

500+
QUnit.test( "outside view position (gh-2836)", function( assert ) {
501+
502+
// This test ported from gh-2836 example
503+
assert.expect( 1 );
504+
505+
var parent,
506+
html = [
507+
"<div id=div-gh-2836>",
508+
"<div></div>",
509+
"<div></div>",
510+
"<div></div>",
511+
"<div></div>",
512+
"<div></div>",
513+
"</div>"
514+
].join( "" ),
515+
stop = assert.async();
516+
517+
parent = $( html );
518+
parent.appendTo( "#qunit-fixture" );
519+
520+
parent.one( "scroll", function() {
521+
var pos = parent.find( "div" ).eq( 3 ).position();
522+
523+
assert.strictEqual(pos.top, -100);
524+
stop();
525+
});
526+
527+
parent.scrollTop( 400 );
528+
} );
529+
500530
} )();

0 commit comments

Comments
 (0)