Commit 1eedf0e9 authored by Oleg Gaidarenko's avatar Oleg Gaidarenko

Dimensions: allow modification of coordinates argument

Ref f7e60dc83d81cbf892de9dab39642dd67c49bd23
parent 38ac3c43
...@@ -57,7 +57,9 @@ jQuery.offset = { ...@@ -57,7 +57,9 @@ jQuery.offset = {
} }
if ( jQuery.isFunction( options ) ) { 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 ) { if ( options.top != null ) {
......
...@@ -470,4 +470,16 @@ testIframe( "dimensions/documentLarge", "window vs. large document", function( j ...@@ -470,4 +470,16 @@ testIframe( "dimensions/documentLarge", "window vs. large document", function( j
ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" ); 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" );
});
})(); })();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment