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.

(cherry-picked from 62ae2d0)

Fixes gh-2147
  • Loading branch information
mgol committed Mar 23, 2015
1 parent 34f2563 commit cd63e9c
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 @@ -468,15 +468,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 cd63e9c

Please sign in to comment.