diff --git a/src/css/curCSS.js b/src/css/curCSS.js index 15d624bbb..25b4630a5 100644 --- a/src/css/curCSS.js +++ b/src/css/curCSS.js @@ -15,7 +15,7 @@ function curCSS( elem, name, computed ) { ret = computed.getPropertyValue( name ) || computed[ name ]; // trim whitespace for custom property (issue gh-4926) - if ( isCustomProp ) { + if ( isCustomProp && ret !== undefined ) { // rtrim treats U+000D CARRIAGE RETURN and U+000C FORM FEED // as whitespace while CSS does not, but this is not a problem diff --git a/test/unit/css.js b/test/unit/css.js index a3e44bb44..b692caac9 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1748,6 +1748,7 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) { " --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" + + " --empty:;\n" + " }\n" + "" ); @@ -1756,7 +1757,7 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) { $elem = jQuery( "