Skip to content

Commit 4de983c

Browse files
meyerteescottgonzalez
authored andcommitted
Position: Add unit tests for bug 8710
Ref #8710 Closes jquerygh-1071
1 parent ebaaca7 commit 4de983c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/unit/position/position.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
<div id="bug-5280" style="height: 30px; width: 201px;">
4848
<div style="width: 50px; height: 10px;"></div>
4949
</div>
50+
51+
<div id="bug-8710-within-smaller" style="position: absolute; width: 100px; height: 99px; top: 0px; left: 0px; line-height: 99px;"></div>
52+
<div id="bug-8710-within-bigger" style="position: absolute; width: 100px; height: 101px; top: 0px; left: 0px; line-height: 101px;"></div>
5053
</div>
5154

5255
</body>

tests/unit/position/position_core.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,4 +726,41 @@ test( "bug #5280: consistent results (avoid fractional values)", function() {
726726
deepEqual( offset1, offset2 );
727727
});
728728

729+
test( "bug #8710: flip if flipped position fits more", function() {
730+
expect( 3 );
731+
732+
// Positions a 10px tall element within 99px height at top 90px.
733+
collisionTest({
734+
within: "#bug-8710-within-smaller",
735+
of: "#parentx",
736+
collision: "flip",
737+
at: "right bottom+30"
738+
}, {
739+
top: 0,
740+
left: 60
741+
}, "flip - top fits all" );
742+
743+
// Positions a 10px tall element within 99px height at top 92px.
744+
collisionTest({
745+
within: "#bug-8710-within-smaller",
746+
of: "#parentx",
747+
collision: "flip",
748+
at: "right bottom+32"
749+
}, {
750+
top: -2,
751+
left: 60
752+
}, "flip - top fits more" );
753+
754+
// Positions a 10px tall element within 101px height at top 92px.
755+
collisionTest({
756+
within: "#bug-8710-within-bigger",
757+
of: "#parentx",
758+
collision: "flip",
759+
at: "right bottom+32"
760+
}, {
761+
top: 92,
762+
left: 60
763+
}, "no flip - top fits less" );
764+
});
765+
729766
}( jQuery ) );

0 commit comments

Comments
 (0)