diff options
author | fecore1 <89127124+fecore1@users.noreply.github.com> | 2021-09-23 19:35:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 13:35:18 +0200 |
commit | efadfe991a5c287af561a9326bf1427d726c91c1 (patch) | |
tree | a8d28d325f3b40a6bac0637ccfa10ac5974dbdf7 /test | |
parent | 175db73ec7938e774d9e93d3afdfb35a24466b47 (diff) | |
download | jquery-efadfe991a5c287af561a9326bf1427d726c91c1.tar.gz jquery-efadfe991a5c287af561a9326bf1427d726c91c1.zip |
CSS: Trim whitespace surrounding CSS Custom Properties values
The spec has recently changed and CSS Custom Properties values are trimmed now.
This change makes jQuery polyfill that new behavior for all browsers.
Ref w3c/csswg-drafts#774
Fixes gh-4926
Closes gh-4930
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/css.js | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/test/unit/css.js b/test/unit/css.js index 8ade482ff..100b8c8c5 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1738,9 +1738,16 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) { " .test__customProperties {\n" + " --prop1:val1;\n" + " --prop2: val2;\n" + - " --prop3:val3 ;\n" + - " --prop4:\"val4\";\n" + - " --prop5:'val5';\n" + + " --prop3: val3;\n" + + " --prop4:val4 ;\n" + + " --prop5:val5 ;\n" + + " --prop6: val6 ;\n" + + " --prop7: val7 ;\n" + + " --prop8:\"val8\";\n" + + " --prop9:'val9';\n" + + " --prop10:\f\r\n\t val10 \f\r\n\t;\n" + + " --prop11:\u000C\u000D\u000A\u0009\u0020val11\u0020\u0009\u000A\u000D\u000C;\n" + + " --prop12:\u000Bval12\u000B;\n" + " }\n" + "</style>" ); @@ -1749,7 +1756,7 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) { $elem = jQuery( "<div>" ).addClass( "test__customProperties" ) .appendTo( "#qunit-fixture" ), webkitOrBlink = /\bsafari\b/i.test( navigator.userAgent ), - expected = 10; + expected = 17; if ( webkitOrBlink ) { expected -= 2; @@ -1777,16 +1784,24 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) { assert.equal( $elem.css( "--prop1" ), "val1", "Basic CSS custom property" ); - assert.equal( $elem.css( "--prop2" ), " val2", "Preceding whitespace maintained" ); - assert.equal( $elem.css( "--prop3" ), "val3 ", "Following whitespace maintained" ); + assert.equal( $elem.css( "--prop2" ), "val2", "Preceding whitespace trimmed" ); + assert.equal( $elem.css( "--prop3" ), "val3", "Multiple preceding whitespace trimmed" ); + assert.equal( $elem.css( "--prop4" ), "val4", "Following whitespace trimmed" ); + assert.equal( $elem.css( "--prop5" ), "val5", "Multiple Following whitespace trimmed" ); + assert.equal( $elem.css( "--prop6" ), "val6", "Preceding and Following whitespace trimmed" ); + assert.equal( $elem.css( "--prop7" ), "val7", "Multiple preceding and following whitespace trimmed" ); // Support: Chrome <=49 - 73+, Safari <=9.1 - 12.1+ // Chrome treats single quotes as double ones. // Safari treats double quotes as single ones. if ( !webkitOrBlink ) { - assert.equal( $elem.css( "--prop4" ), "\"val4\"", "Works with double quotes" ); - assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" ); + assert.equal( $elem.css( "--prop8" ), "\"val8\"", "Works with double quotes" ); + assert.equal( $elem.css( "--prop9" ), "'val9'", "Works with single quotes" ); } + + assert.equal( $elem.css( "--prop10" ), "val10", "Multiple preceding and following escaped unicode whitespace trimmed" ); + assert.equal( $elem.css( "--prop11" ), "val11", "Multiple preceding and following unicode whitespace trimmed" ); + assert.equal( $elem.css( "--prop12" ), "\u000Bval12\u000B", "Multiple preceding and following non-CSS whitespace reserved" ); } ); // IE doesn't support CSS variables. |