Skip to content

Commit 62ae2d0

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. Fixes gh-2147
1 parent 555a50d commit 62ae2d0

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
@@ -453,15 +453,18 @@ testIframe( "dimensions/documentLarge", "window vs. large document", function( j
453453
});
454454

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

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

461462
return coords;
462463
});
463464

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

467470
})();

0 commit comments

Comments
 (0)