]> source.dussan.org Git - jquery.git/commitdiff
Tests: Workaround a tr width test issue in old iOS
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 13 Nov 2023 17:12:23 +0000 (18:12 +0100)
committerGitHub <noreply@github.com>
Mon, 13 Nov 2023 17:12:23 +0000 (18:12 +0100)
Old iOS (<10) always rounds widths down, account for this in tests.

Closes gh-5361
Ref gh-5317
Ref gh-5359

test/unit/css.js

index a1c5267d75d2cda238caafa8f404b622e6543303..2603e73d9b27ba65b8503a4b7513fd92cb792f87 100644 (file)
@@ -1402,7 +1402,7 @@ testIframe(
 );
 
 ( function() {
-       var supportsFractionalTrWidth,
+       var supportsFractionalTrWidth, trWidth,
                epsilon = 0.1,
                table = jQuery( "<table><tr></tr></table>" ),
                tr = table.find( "tr" );
@@ -1429,12 +1429,16 @@ testIframe(
                        jQuery( "#test" ).width( 600 );
                        assert.strictEqual( jQuery( "#test" ).width(), 600, "width should be 600" );
 
+                       trWidth = jQuery( "#test-tr" ).width();
                        if ( supportsFractionalTrWidth ) {
                                assert.ok(
-                                       Math.abs( jQuery( "#test-tr" ).width() - 100.7 ) < epsilon,
+                                       Math.abs( trWidth - 100.7 ) < epsilon,
                                        "tr width should be fractional" );
                        } else {
-                               assert.strictEqual( jQuery( "#test-tr" ).width(), 101, "tr width as expected" );
+
+                               // Support: iOS <10
+                               // Old iOS always rounds down.
+                               assert.strictEqual( trWidth === 100 ? 101 : trWidth, 101, "tr width as expected" );
                        }
                },
                undefined,