@@ -1198,14 +1198,17 @@ if ( jQuery.fn.offset ) {
11981198}
11991199
12001200QUnit . test ( "Do not append px (#9548, #12990, #2792)" , function ( assert ) {
1201- assert . expect ( 3 ) ;
1201+ assert . expect ( 4 ) ;
12021202
12031203 var $div = jQuery ( "<div>" ) . appendTo ( "#qunit-fixture" ) ;
12041204
12051205 $div . css ( "fill-opacity" , 1 ) ;
1206-
12071206 assert . equal ( $div . css ( "fill-opacity" ) , 1 , "Do not append px to 'fill-opacity'" ) ;
12081207
1208+ $div . css ( "font-size" , "27px" ) ;
1209+ $div . css ( "line-height" , 2 ) ;
1210+ assert . equal ( $div . css ( "line-height" ) , "54px" , "Do not append px to 'line-height'" ) ;
1211+
12091212 $div . css ( "column-count" , 1 ) ;
12101213 if ( $div . css ( "column-count" ) !== undefined ) {
12111214 assert . equal ( $div . css ( "column-count" ) , 1 , "Do not append px to 'column-count'" ) ;
@@ -1273,6 +1276,77 @@ QUnit[
12731276 }
12741277} ) ;
12751278
1279+ QUnit . test ( "Do not append px to most properties not accepting integer values" , function ( assert ) {
1280+ assert . expect ( 3 ) ;
1281+
1282+ var $div = jQuery ( "<div>" ) . appendTo ( "#qunit-fixture" ) ;
1283+
1284+ $div . css ( "font-size" , "27px" ) ;
1285+
1286+ $div . css ( "font-size" , 2 ) ;
1287+ assert . equal ( $div . css ( "font-size" ) , "27px" , "Do not append px to 'font-size'" ) ;
1288+
1289+ $div . css ( "fontSize" , 2 ) ;
1290+ assert . equal ( $div . css ( "fontSize" ) , "27px" , "Do not append px to 'fontSize'" ) ;
1291+
1292+ $div . css ( "letter-spacing" , "2px" ) ;
1293+ $div . css ( "letter-spacing" , 3 ) ;
1294+ assert . equal ( $div . css ( "letter-spacing" ) , "2px" , "Do not append px to 'letter-spacing'" ) ;
1295+ } ) ;
1296+
1297+ QUnit . test ( "Append px to whitelisted properties" , function ( assert ) {
1298+ var prop ,
1299+ $div = jQuery ( "<div>" ) . appendTo ( "#qunit-fixture" ) ,
1300+ whitelist = {
1301+ margin : "marginTop" ,
1302+ marginTop : undefined ,
1303+ marginRight : undefined ,
1304+ marginBottom : undefined ,
1305+ marginLeft : undefined ,
1306+ padding : "paddingTop" ,
1307+ paddingTop : undefined ,
1308+ paddingRight : undefined ,
1309+ paddingBottom : undefined ,
1310+ paddingLeft : undefined ,
1311+ top : undefined ,
1312+ right : undefined ,
1313+ bottom : undefined ,
1314+ left : undefined ,
1315+ width : undefined ,
1316+ height : undefined ,
1317+ minWidth : undefined ,
1318+ minHeight : undefined ,
1319+ maxWidth : undefined ,
1320+ maxHeight : undefined ,
1321+ border : "borderTopWidth" ,
1322+ borderWidth : "borderTopWidth" ,
1323+ borderTop : "borderTopWidth" ,
1324+ borderTopWidth : undefined ,
1325+ borderRight : "borderRightWidth" ,
1326+ borderRightWidth : undefined ,
1327+ borderBottom : "borderBottomWidth" ,
1328+ borderBottomWidth : undefined ,
1329+ borderLeft : "borderLeftWidth" ,
1330+ borderLeftWidth : undefined
1331+ } ;
1332+
1333+ assert . expect ( ( Object . keys ( whitelist ) . length ) * 2 ) ;
1334+
1335+ for ( prop in whitelist ) {
1336+ var propToCheck = whitelist [ prop ] || prop ,
1337+ kebabProp = prop . replace ( / [ A - Z ] / g, function ( match ) {
1338+ return "-" + match . toLowerCase ( ) ;
1339+ } ) ,
1340+ kebabPropToCheck = propToCheck . replace ( / [ A - Z ] / g, function ( match ) {
1341+ return "-" + match . toLowerCase ( ) ;
1342+ } ) ;
1343+ $div . css ( prop , 3 ) . css ( "border-style" , "solid" ) ;
1344+ assert . equal ( $div . css ( propToCheck ) , "3px" , "Append px to '" + prop + "'" ) ;
1345+ $div . css ( kebabProp , 3 ) . css ( "border-style" , "solid" ) ;
1346+ assert . equal ( $div . css ( kebabPropToCheck ) , "3px" , "Append px to '" + kebabProp + "'" ) ;
1347+ }
1348+ } ) ;
1349+
12761350QUnit . test ( "css('width') and css('height') should respect box-sizing, see #11004" , function ( assert ) {
12771351 assert . expect ( 4 ) ;
12781352
0 commit comments