Permalink
Browse files

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
  • Loading branch information...
mgol committed Mar 16, 2015
1 parent 555a50d commit 62ae2d0fb7ac011bf2ad778f8158de408e785927
Showing with 5 additions and 2 deletions.
  1. +5 −2 test/unit/dimensions.js
View
@@ -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 62ae2d0

Please sign in to comment.