mirror of
https://github.com/jquery/jquery.git
synced 2024-10-05 11:34:18 +00:00
Offset: add tests for hidden elements + scroll
- Also add comments to hidden/disconnected tests noting this is to ensure consistency between branches
This commit is contained in:
parent
0e4477c676
commit
b041242223
@ -11,6 +11,7 @@
|
||||
#scroll-1-1 { top: 1px; left: 1px; }
|
||||
#scroll-1-1-1 { top: 1px; left: 1px; }
|
||||
#forceScroll { width: 5000px; height: 5000px; }
|
||||
#hidden { display: none; }
|
||||
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
||||
</style>
|
||||
<script src="../../jquery.js"></script>
|
||||
@ -32,6 +33,7 @@
|
||||
<div id="scroll-1-1-1" class="scroll"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="hidden"></div>
|
||||
<div id="forceScroll"></div>
|
||||
<div id="marker"></div>
|
||||
<p class="instructions">Click the white box to move the marker to it.</p>
|
||||
|
@ -52,6 +52,9 @@ test("disconnected element", function() {
|
||||
|
||||
var result = jQuery( document.createElement( "div" ) ).offset();
|
||||
|
||||
// These tests are solely for master/compat consistency
|
||||
// Retrieving offset on disconnected/hidden elements is not officially
|
||||
// valid input, but will return zeros for back-compat
|
||||
equal( result.top, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
|
||||
equal( result.left, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
|
||||
});
|
||||
@ -64,6 +67,9 @@ test("hidden (display: none) element", function() {
|
||||
|
||||
node.remove();
|
||||
|
||||
// These tests are solely for master/compat consistency
|
||||
// Retrieving offset on disconnected/hidden elements is not officially
|
||||
// valid input, but will return zeros for back-compat
|
||||
equal( result.top, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" );
|
||||
equal( result.left, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" );
|
||||
});
|
||||
@ -401,7 +407,7 @@ testIframe("offset/table", "table", function( $ ) {
|
||||
});
|
||||
|
||||
testIframe("offset/scroll", "scroll", function( $, win ) {
|
||||
expect(28);
|
||||
expect( 30 );
|
||||
|
||||
equal( $("#scroll-1").offset().top, 7, "jQuery('#scroll-1').offset().top" );
|
||||
equal( $("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
||||
@ -409,6 +415,12 @@ testIframe("offset/scroll", "scroll", function( $, win ) {
|
||||
equal( $("#scroll-1-1").offset().top, 11, "jQuery('#scroll-1-1').offset().top" );
|
||||
equal( $("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
|
||||
// These tests are solely for master/compat consistency
|
||||
// Retrieving offset on disconnected/hidden elements is not officially
|
||||
// valid input, but will return zeros for back-compat
|
||||
equal( $("#hidden").offset().top, 0, "Hidden elements do not subtract scroll" );
|
||||
equal( $("#hidden").offset().left, 0, "Hidden elements do not subtract scroll" );
|
||||
|
||||
// scroll offset tests .scrollTop/Left
|
||||
equal( $("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
||||
equal( $("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
||||
|
Loading…
Reference in New Issue
Block a user