Skip to content

Commit cd63e9c

Browse files
committed
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. (cherry-picked from 62ae2d0) Fixes gh-2147
1 parent 34f2563 commit cd63e9c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/unit/dimensions.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,15 +468,18 @@ testIframe( "dimensions/documentLarge", "window vs. large document", function( j
468468
});
469469

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

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

476477
return coords;
477478
});
478479

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

482485
})();

0 commit comments

Comments
 (0)