From 93ca49e6d1ac23fee33b3bc3b7f4d93dd1a25cb7 Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski-Owczarek Date: Wed, 20 Sep 2023 00:54:40 +0200 Subject: Core: Simplify code post browser support reduction Summary of the changes: * Core: Simplify code post browser support reduction * Tests: Remove legacy jQuery.cache & oldIE leftovers * Tests: Reformat JavaScript in delegatetest.html * Docs: "jQuery Foundation Projects" -> "jQuery Projects" * Tests: Drop an unused localfile.html file (modern browsers don't support the `file:` protocol this way, there's no point in keeping the file around) * Effects: Remove a redundant `!fn` check (`fn || !fn && easing` is equivalent to `fn || easing`; simplify the code) * CSS: Explain the fallback to direct object access in curCSS better * Tests: Deduplicate `jQuery.parseHTML` test titles * Dimensions: Add a test for fractional values * Tests: Fix a buggy WebKit regex Closes gh-5296 --- test/data/testinit.js | 16 +++--- test/delegatetest.html | 130 +++++++++++++++++++++++------------------------- test/localfile.html | 75 ---------------------------- test/unit/core.js | 2 +- test/unit/css.js | 2 +- test/unit/dimensions.js | 24 +++++++++ test/unit/wrap.js | 2 +- 7 files changed, 94 insertions(+), 157 deletions(-) delete mode 100644 test/localfile.html (limited to 'test') diff --git a/test/data/testinit.js b/test/data/testinit.js index baf758205..aafe2902c 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -144,16 +144,12 @@ this.createXMLFragment = function() { return frag; }; -window.fireNative = document.createEvent ? - function( node, type ) { - var event = document.createEvent( "HTMLEvents" ); - - event.initEvent( type, true, true ); - node.dispatchEvent( event ); - } : - function( node, type ) { - node.fireEvent( "on" + type, document.createEventObject() ); - }; +window.fireNative = function( node, type ) { + var event = document.createEvent( "HTMLEvents" ); + + event.initEvent( type, true, true ); + node.dispatchEvent( event ); +}; /** * Add random number to url to stop caching diff --git a/test/delegatetest.html b/test/delegatetest.html index d3225196e..53efe54ce 100644 --- a/test/delegatetest.html +++ b/test/delegatetest.html @@ -125,103 +125,95 @@ th, td { diff --git a/test/localfile.html b/test/localfile.html deleted file mode 100644 index 5a79bfec1..000000000 --- a/test/localfile.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - jQuery Local File Test - - - - - -

jQuery Local File Test

-

- Introduction -

- -

- Results -

- -

- Logs: -

- - - diff --git a/test/unit/core.js b/test/unit/core.js index 294664d5c..666f0e820 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -1403,7 +1403,7 @@ QUnit.test( "jQuery.parseHTML() - gh-2965", function( assert ) { assert.ok( /\/example\.html$/.test( href ), "href is not lost after parsing anchor" ); } ); -QUnit.test( "jQuery.parseHTML", function( assert ) { +QUnit.test( "jQuery.parseHTML error handling", function( assert ) { var done = assert.async(); assert.expect( 1 ); diff --git a/test/unit/css.js b/test/unit/css.js index 31d043544..146dcd9da 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1757,7 +1757,7 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) { var div = jQuery( "
" ).appendTo( "#qunit-fixture" ), $elem = jQuery( "
" ).addClass( "test__customProperties" ) .appendTo( "#qunit-fixture" ), - webkitOrBlink = /\webkit\b/i.test( navigator.userAgent ), + webkitOrBlink = /webkit\b/i.test( navigator.userAgent ), expected = 20; if ( webkitOrBlink ) { diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index 85a69cdb7..6b0c9c798 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -284,6 +284,30 @@ QUnit.test( "outerHeight()", function( assert ) { div.remove(); } ); +QUnit.test( "fractional getters", function( assert ) { + assert.expect( 8 ); + + var elem = jQuery( "
" ).css( { + width: "10.5px", + height: "20.5px", + border: "10px solid white", + padding: "2px", + margin: "3px" + } ); + + elem.appendTo( "#qunit-fixture" ); + + assert.strictEqual( elem.width(), 10.5, "width supports fractions" ); + assert.strictEqual( elem.innerWidth(), 14.5, "innerWidth supports fractions" ); + assert.strictEqual( elem.outerWidth(), 34.5, "outerWidth supports fractions" ); + assert.strictEqual( elem.outerWidth( true ), 40.5, "outerWidth( true ) supports fractions" ); + + assert.strictEqual( elem.height(), 20.5, "height supports fractions" ); + assert.strictEqual( elem.innerHeight(), 24.5, "innerHeight supports fractions" ); + assert.strictEqual( elem.outerHeight(), 44.5, "outerHeight supports fractions" ); + assert.strictEqual( elem.outerHeight( true ), 50.5, "outerHeight( true ) supports fractions" ); +} ); + QUnit.test( "child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see trac-9441 trac-9300", function( assert ) { assert.expect( 16 ); diff --git a/test/unit/wrap.js b/test/unit/wrap.js index 24136ac0e..31f9cd300 100644 --- a/test/unit/wrap.js +++ b/test/unit/wrap.js @@ -23,7 +23,7 @@ function testWrap( val, assert ) { assert.expect( 18 ); - var defaultText, result, j, i, cacheLength; + var defaultText, result, j; defaultText = "Try them out:"; result = jQuery( "#first" ).wrap( val( "
" ) ).text(); -- cgit v1.2.3