+ // set offset
+ tests = [
+ { id: '#absolute-2', top: 30, left: 30 },
+ { id: '#absolute-2', top: 10, left: 10 },
+ { id: '#absolute-2', top: -1, left: -1 },
+ { id: '#absolute-2', top: 19, left: 19 },
+ { id: '#absolute-1-1-1', top: 15, left: 15 },
+ { id: '#absolute-1-1-1', top: 5, left: 5 },
+ { id: '#absolute-1-1-1', top: -1, left: -1 },
+ { id: '#absolute-1-1-1', top: 9, left: 9 },
+ { id: '#absolute-1-1', top: 10, left: 10 },
+ { id: '#absolute-1-1', top: 0, left: 0 },
+ { id: '#absolute-1-1', top: -1, left: -1 },
+ { id: '#absolute-1-1', top: 5, left: 5 },
+ { id: '#absolute-1', top: 2, left: 2 },
+ { id: '#absolute-1', top: 0, left: 0 },
+ { id: '#absolute-1', top: -1, left: -1 },
+ { id: '#absolute-1', top: 1, left: 1 }
+ ];
+ jQuery.each( tests, function() {
+ jQuery( this.id ).offset({ top: this.top, left: this.left });
+ equals( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
+ equals( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
+
+ var top = this.top, left = this.left;
+
+ jQuery( this.id ).offset(function(i, val){
+ equals( val.top, top, "Verify incoming top position." );
+ equals( val.left, left, "Verify incoming top position." );
+ return { top: top + 1, left: left + 1 };
+ });
+ equals( jQuery( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
+ equals( jQuery( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
+
+ jQuery( this.id ).offset({ top: this.top, left: this.left, using: function( props ) {
+ jQuery( this ).css({
+ top: props.top + 1,
+ left: props.left + 1
+ });
+ }});
+ equals( jQuery( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + (this.top + 1) + ", using: fn })" );
+ equals( jQuery( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + (this.left + 1) + ", using: fn })" );
+ });