From: Michał Gołębiowski Date: Mon, 16 Mar 2015 17:23:21 +0000 (+0100) Subject: Offset: Round offset value for the sake of floating errors X-Git-Tag: 3.0.0-alpha1~95 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=62ae2d0fb7ac011bf2ad778f8158de408e785927;p=jquery.git Offset: Round offset value for the sake of floating errors 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 gh-2147 --- diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index d0e7ea2b8..7e3177161 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -453,7 +453,8 @@ testIframe( "dimensions/documentLarge", "window vs. large document", function( j }); test( "allow modification of coordinates argument (gh-1848)", 1, function() { - var element = jQuery( "
" ).appendTo( "#qunit-fixture" ); + var offsetTop, + element = jQuery( "
" ).appendTo( "#qunit-fixture" ); element.offset(function( index, coords ) { coords.top = 100; @@ -461,7 +462,9 @@ test( "allow modification of coordinates argument (gh-1848)", 1, function() { 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 + ")"); }); })();