mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
CSS: Don't auto-append "px" to CSS variables (#4064)
Fixes gh-4063 Closes gh-4064
This commit is contained in:
parent
45f0858825
commit
75b77b4873
@ -246,7 +246,9 @@ jQuery.extend( {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If a number was passed in, add the unit (except for certain CSS properties)
|
// If a number was passed in, add the unit (except for certain CSS properties)
|
||||||
if ( type === "number" ) {
|
// The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
|
||||||
|
// "px" to a few hardcoded values.
|
||||||
|
if ( type === "number" && !isCustomProp ) {
|
||||||
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
|
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1659,6 +1659,21 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function(
|
|||||||
assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" );
|
assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
QUnit[ supportsCssVars ? "test" : "skip" ]( "Don't append px to CSS vars", function( assert ) {
|
||||||
|
assert.expect( 3 );
|
||||||
|
|
||||||
|
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );
|
||||||
|
|
||||||
|
$div
|
||||||
|
.css( "--a", 3 )
|
||||||
|
.css( "--line-height", 4 )
|
||||||
|
.css( "--lineHeight", 5 );
|
||||||
|
|
||||||
|
assert.equal( $div.css( "--a" ), "3", "--a: 3" );
|
||||||
|
assert.equal( $div.css( "--line-height" ), "4", "--line-height: 4" );
|
||||||
|
assert.equal( $div.css( "--lineHeight" ), "5", "--lineHeight: 5" );
|
||||||
|
} );
|
||||||
} )();
|
} )();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user