#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>
<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>
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)" );
});
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)" );
});
});
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" );
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()" );