Fixed an issue with setting offset of absolutely positioned element that has no position values ("auto"). Fixes #5781.

This commit is contained in:
Brandon Aaron 2010-03-22 20:11:37 -04:00
parent 08cf82e88e
commit 656fe92178
3 changed files with 29 additions and 9 deletions

View file

@ -35,7 +35,7 @@ testoffset("absolute"/* in iframe */, function($, iframe) {
});
testoffset("absolute", function( jQuery ) {
expect(176);
expect(178);
// get offset tests
var tests = [
@ -62,6 +62,11 @@ testoffset("absolute", function( jQuery ) {
equals( jQuery( this.id ).position().left, this.left, "jQuery('" + this.id + "').position().left" );
});
// test #5781
var offset = jQuery( '#positionTest' ).offset({ top: 10, left: 10 }).offset();
equals( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." )
equals( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." )
// set offset
tests = [
@ -97,8 +102,9 @@ testoffset("absolute", function( jQuery ) {
equals( jQuery( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + (this.top + 1) + " })" );
equals( jQuery( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + (this.left + 1) + " })" );
jQuery( this.id ).offset({ top: this.top + 2 });
jQuery( this.id ).offset({ left: this.left + 2 });
jQuery( this.id )
.offset({ left: this.left + 2 })
.offset({ top: this.top + 2 });
equals( jQuery( this.id ).offset().top, this.top + 2, "Setting one property at a time." );
equals( jQuery( this.id ).offset().left, this.left + 2, "Setting one property at a time." );