aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorMichał Gołębiowski <m.goleb@gmail.com>2015-03-16 18:23:21 +0100
committerMichał Gołębiowski <m.goleb@gmail.com>2015-03-23 18:30:05 +0100
commitcd63e9c622b82a110d8453cc9a128fcf9ea6ade4 (patch)
tree70b1795b8fa43dc453971f61f1efaaf548ce7706 /test/unit
parent34f25631795e0641cc706012cfe5a88dacdedfec (diff)
downloadjquery-cd63e9c622b82a110d8453cc9a128fcf9ea6ade4.tar.gz
jquery-cd63e9c622b82a110d8453cc9a128fcf9ea6ade4.zip
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 62ae2d0fb7ac011bf2ad778f8158de408e785927) Fixes gh-2147
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/dimensions.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js
index c3bf71a63..6a8453902 100644
--- a/test/unit/dimensions.js
+++ b/test/unit/dimensions.js
@@ -468,7 +468,8 @@ 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;
@@ -476,7 +477,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 + ")");
});
})();