@@ -1118,14 +1118,17 @@ if ( jQuery.fn.offset ) {
11181118}
11191119
11201120QUnit . test ( "Do not append px (#9548, #12990, #2792)" , function ( assert ) {
1121- assert . expect ( 3 ) ;
1121+ assert . expect ( 4 ) ;
11221122
11231123 var $div = jQuery ( "<div>" ) . appendTo ( "#qunit-fixture" ) ;
11241124
11251125 $div . css ( "fill-opacity" , 1 ) ;
1126-
11271126 assert . equal ( $div . css ( "fill-opacity" ) , 1 , "Do not append px to 'fill-opacity'" ) ;
11281127
1128+ $div . css ( "font-size" , "27px" ) ;
1129+ $div . css ( "line-height" , 2 ) ;
1130+ assert . equal ( $div . css ( "line-height" ) , "54px" , "Do not append px to 'line-height'" ) ;
1131+
11291132 $div . css ( "column-count" , 1 ) ;
11301133 if ( $div . css ( "column-count" ) !== undefined ) {
11311134 assert . equal ( $div . css ( "column-count" ) , 1 , "Do not append px to 'column-count'" ) ;
@@ -1143,6 +1146,77 @@ QUnit.test( "Do not append px (#9548, #12990, #2792)", function( assert ) {
11431146 }
11441147} ) ;
11451148
1149+ QUnit . test ( "Do not append px to most properties not accepting integer values" , function ( assert ) {
1150+ assert . expect ( 3 ) ;
1151+
1152+ var $div = jQuery ( "<div>" ) . appendTo ( "#qunit-fixture" ) ;
1153+
1154+ $div . css ( "font-size" , "27px" ) ;
1155+
1156+ $div . css ( "font-size" , 2 ) ;
1157+ assert . equal ( $div . css ( "font-size" ) , "27px" , "Do not append px to 'font-size'" ) ;
1158+
1159+ $div . css ( "fontSize" , 2 ) ;
1160+ assert . equal ( $div . css ( "fontSize" ) , "27px" , "Do not append px to 'fontSize'" ) ;
1161+
1162+ $div . css ( "letter-spacing" , "2px" ) ;
1163+ $div . css ( "letter-spacing" , 3 ) ;
1164+ assert . equal ( $div . css ( "letter-spacing" ) , "2px" , "Do not append px to 'letter-spacing'" ) ;
1165+ } ) ;
1166+
1167+ QUnit . test ( "Append px to whitelisted properties" , function ( assert ) {
1168+ var prop ,
1169+ $div = jQuery ( "<div>" ) . appendTo ( "#qunit-fixture" ) ,
1170+ whitelist = {
1171+ margin : undefined ,
1172+ marginTop : undefined ,
1173+ marginRight : undefined ,
1174+ marginBottom : undefined ,
1175+ marginLeft : undefined ,
1176+ padding : undefined ,
1177+ paddingTop : undefined ,
1178+ paddingRight : undefined ,
1179+ paddingBottom : undefined ,
1180+ paddingLeft : undefined ,
1181+ top : undefined ,
1182+ right : undefined ,
1183+ bottom : undefined ,
1184+ left : undefined ,
1185+ width : undefined ,
1186+ height : undefined ,
1187+ minWidth : undefined ,
1188+ minHeight : undefined ,
1189+ maxWidth : undefined ,
1190+ maxHeight : undefined ,
1191+ border : "borderTopWidth" ,
1192+ borderWidth : "borderTopWidth" ,
1193+ borderTop : "borderTopWidth" ,
1194+ borderTopWidth : "borderTopWidth" ,
1195+ borderRight : "borderRightWidth" ,
1196+ borderRightWidth : "borderRightWidth" ,
1197+ borderBottom : "borderBottomWidth" ,
1198+ borderBottomWidth : "borderBottomWidth" ,
1199+ borderLeft : "borderLeftWidth" ,
1200+ borderLeftWidth : "borderLeftWidth"
1201+ } ;
1202+
1203+ assert . expect ( ( Object . keys ( whitelist ) . length ) * 2 ) ;
1204+
1205+ for ( prop in whitelist ) {
1206+ var propToCheck = whitelist [ prop ] || prop ,
1207+ kebabProp = prop . replace ( / [ A - Z ] / g, function ( match ) {
1208+ return "-" + match . toLowerCase ( ) ;
1209+ } ) ,
1210+ kebabPropToCheck = propToCheck . replace ( / [ A - Z ] / g, function ( match ) {
1211+ return "-" + match . toLowerCase ( ) ;
1212+ } ) ;
1213+ $div . css ( prop , 3 ) . css ( "border-style" , "solid" ) ;
1214+ assert . equal ( $div . css ( propToCheck ) , "3px" , "Append px to '" + prop + "'" ) ;
1215+ $div . css ( kebabProp , 3 ) . css ( "border-style" , "solid" ) ;
1216+ assert . equal ( $div . css ( kebabPropToCheck ) , "3px" , "Append px to '" + kebabProp + "'" ) ;
1217+ }
1218+ } ) ;
1219+
11461220QUnit . test ( "css('width') and css('height') should respect box-sizing, see #11004" , function ( assert ) {
11471221 assert . expect ( 4 ) ;
11481222
0 commit comments