Skip to content

Commit

Permalink
Offset: Round offset value for the sake of floating errors
Browse files Browse the repository at this point in the history
IE10+ may return not exactly the offset.top value set in an offset callback
if parent has fractional top offset itself. Checking for being close to the
desired result fixes the test error.

Fixes jquerygh-2147
  • Loading branch information
mgol committed Mar 16, 2015
1 parent 5dc4616 commit f64c0db
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/unit/dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,18 @@ testIframe( "dimensions/documentLarge", "window vs. large document", function( j
});

test( "allow modification of coordinates argument (gh-1848)", 1, function() {
var element = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
var offsetTop,
element = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );

element.offset(function( index, coords ) {
coords.top = 100;

return coords;
});

equal( element.offset().top, 100, "coordinates are modified" );
offsetTop = element.offset().top;
ok( Math.abs(offsetTop - 100) < 0.02,
"coordinates are modified (got offset.top: " + offsetTop + ")");
});

})();

0 comments on commit f64c0db

Please sign in to comment.