Fixes gh-1848
Closes gh-1853
}
if ( jQuery.isFunction( options ) ) {
- options = options.call( elem, i, curOffset );
+
+ // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
+ options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
}
if ( options.top != null ) {
ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" );
});
+test( "allow modification of coordinates argument (gh-1848)", 1, function() {
+ var element = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
+
+ element.offset(function( index, coords ) {
+ coords.top = 100;
+
+ return coords;
+ });
+
+ equal( element.offset().top, 100, "coordinates are modified" );
+});
+
})();