@@ -1157,7 +1157,7 @@ describe('properties: custom property', () => {
1157
1157
test ( 'legacy strings' , ( ) => {
1158
1158
const options = {
1159
1159
customProperties : {
1160
- rootColor : 'red'
1160
+ '-- rootColor' : 'red'
1161
1161
}
1162
1162
} ;
1163
1163
expect (
@@ -1183,7 +1183,8 @@ describe('properties: custom property', () => {
1183
1183
themeAwareColor : {
1184
1184
default : 'blue' ,
1185
1185
'@media (prefers-color-scheme: dark)' : 'green'
1186
- }
1186
+ } ,
1187
+ '--pass-through' : 'purple'
1187
1188
} ) ;
1188
1189
expect ( tokens ) . toMatchSnapshot ( 'tokens' ) ;
1189
1190
expect ( css . __customProperties ) . toMatchSnapshot ( 'css.__customProperties' ) ;
@@ -1193,6 +1194,9 @@ describe('properties: custom property', () => {
1193
1194
expect (
1194
1195
resolveCustomPropertyValue ( options , [ 'color' , tokens . themeAwareColor ] )
1195
1196
) . toEqual ( 'blue' ) ;
1197
+ expect (
1198
+ resolveCustomPropertyValue ( options , [ 'color' , 'var(--pass-through)' ] )
1199
+ ) . toEqual ( 'purple' ) ;
1196
1200
// dark theme
1197
1201
expect (
1198
1202
resolveCustomPropertyValue ( { colorScheme : 'dark' } , [
@@ -1255,7 +1259,9 @@ describe('properties: custom property', () => {
1255
1259
1256
1260
test ( 'parses a basic var correctly' , ( ) => {
1257
1261
const options = {
1258
- customProperties : { test : 'red' }
1262
+ customProperties : {
1263
+ '--test' : 'red'
1264
+ }
1259
1265
} ;
1260
1266
expect (
1261
1267
resolveCustomPropertyValue ( options , [ 'color' , 'var(--test)' ] )
@@ -1264,7 +1270,9 @@ describe('properties: custom property', () => {
1264
1270
1265
1271
test ( 'parses a var with a default value' , ( ) => {
1266
1272
const options = {
1267
- customProperties : { test : 'red' }
1273
+ customProperties : {
1274
+ '--test' : 'red'
1275
+ }
1268
1276
} ;
1269
1277
expect (
1270
1278
resolveCustomPropertyValue ( options , [ 'color' , 'var(--test, blue)' ] )
@@ -1274,32 +1282,11 @@ describe('properties: custom property', () => {
1274
1282
) . toEqual ( 'blue' ) ;
1275
1283
} ) ;
1276
1284
1277
- // TODO: this transform should not be supported. Custom properties are case sensitive.
1278
- test ( 'parses kebab case var to camel case' , ( ) => {
1279
- const options = {
1280
- customProperties : { testVar : 'red' }
1281
- } ;
1282
- expect (
1283
- resolveCustomPropertyValue ( options , [ 'color' , 'var(--test-var)' ] )
1284
- ) . toEqual ( 'red' ) ;
1285
- } ) ;
1286
-
1287
- // TODO: this transform should not be supported. Custom properties are case sensitive.
1288
- test ( 'parses kebab case var with a default value' , ( ) => {
1289
- const options = {
1290
- customProperties : { testVar : 'red' }
1291
- } ;
1292
- expect (
1293
- resolveCustomPropertyValue ( options , [ 'color' , 'var(--test-var, blue)' ] )
1294
- ) . toEqual ( 'red' ) ;
1295
- expect (
1296
- resolveCustomPropertyValue ( options , [ 'color' , 'var(--not-found, blue)' ] )
1297
- ) . toEqual ( 'blue' ) ;
1298
- } ) ;
1299
-
1300
1285
test ( 'parses a var with a default value containing spaces' , ( ) => {
1301
1286
const options = {
1302
- customProperties : { color : 'rgb(0,0,0)' }
1287
+ customProperties : {
1288
+ '--color' : 'rgb(0,0,0)'
1289
+ }
1303
1290
} ;
1304
1291
expect (
1305
1292
resolveCustomPropertyValue ( options , [
@@ -1317,7 +1304,9 @@ describe('properties: custom property', () => {
1317
1304
1318
1305
test ( 'parses a var and falls back to default value containing a var' , ( ) => {
1319
1306
const options = {
1320
- customProperties : { color : 'red' }
1307
+ customProperties : {
1308
+ '--color' : 'red'
1309
+ }
1321
1310
} ;
1322
1311
expect (
1323
1312
resolveCustomPropertyValue ( options , [
@@ -1330,7 +1319,7 @@ describe('properties: custom property', () => {
1330
1319
test ( 'parses a var and falls back to a default value containing spaces and embedded var' , ( ) => {
1331
1320
const options = {
1332
1321
customProperties : {
1333
- test : '255'
1322
+ '-- test' : '255'
1334
1323
}
1335
1324
} ;
1336
1325
expect (
@@ -1343,7 +1332,9 @@ describe('properties: custom property', () => {
1343
1332
1344
1333
test ( 'basic var value lookup works' , ( ) => {
1345
1334
const options = {
1346
- customProperties : { number : 10 }
1335
+ customProperties : {
1336
+ '--number' : 10
1337
+ }
1347
1338
} ;
1348
1339
expect (
1349
1340
resolveCustomPropertyValue ( options , [ 'borderWidth' , 'var(--number)' ] )
@@ -1352,7 +1343,9 @@ describe('properties: custom property', () => {
1352
1343
1353
1344
test ( 'var value lookup with pixel prop conversion' , ( ) => {
1354
1345
const options = {
1355
- customProperties : { pxNumber : '10px' }
1346
+ customProperties : {
1347
+ '--pxNumber' : '10px'
1348
+ }
1356
1349
} ;
1357
1350
expect (
1358
1351
resolveCustomPropertyValue ( options , [ 'borderWidth' , 'var(--pxNumber)' ] )
@@ -1361,7 +1354,9 @@ describe('properties: custom property', () => {
1361
1354
1362
1355
test ( 'var value lookup with em prop conversion' , ( ) => {
1363
1356
const options = {
1364
- customProperties : { emNumber : '10em' }
1357
+ customProperties : {
1358
+ '--emNumber' : '10em'
1359
+ }
1365
1360
} ;
1366
1361
expect (
1367
1362
resolveCustomPropertyValue ( options , [ 'borderWidth' , 'var(--emNumber)' ] )
@@ -1371,9 +1366,9 @@ describe('properties: custom property', () => {
1371
1366
test ( 'var value lookup with reference to another var' , ( ) => {
1372
1367
const options = {
1373
1368
customProperties : {
1374
- number : 10 ,
1375
- refToNumber : 'var(--number)' ,
1376
- refToRefToNumber : 'var(--refToNumber)'
1369
+ '-- number' : 10 ,
1370
+ '-- refToNumber' : 'var(--number)' ,
1371
+ '-- refToRefToNumber' : 'var(--refToNumber)'
1377
1372
}
1378
1373
} ;
1379
1374
expect (
@@ -1389,7 +1384,9 @@ describe('properties: custom property', () => {
1389
1384
1390
1385
test ( 'var with hover styles' , ( ) => {
1391
1386
const options = {
1392
- customProperties : { test : '#333' } ,
1387
+ customProperties : {
1388
+ '--test' : '#333'
1389
+ } ,
1393
1390
hover : true
1394
1391
} ;
1395
1392
const { underTest } = css . create ( {
@@ -1413,7 +1410,9 @@ describe('properties: custom property', () => {
1413
1410
1414
1411
test ( 'rgb(a) function with args applied through a single var' , ( ) => {
1415
1412
const options = {
1416
- customProperties : { example : '24, 48, 96' }
1413
+ customProperties : {
1414
+ '--example' : '24, 48, 96'
1415
+ }
1417
1416
} ;
1418
1417
expect (
1419
1418
resolveCustomPropertyValue ( options , [ 'color' , 'rgb(var(--example))' ] )
@@ -1429,11 +1428,11 @@ describe('properties: custom property', () => {
1429
1428
test ( 'rgba function with args applied through multiple (& nested) vars' , ( ) => {
1430
1429
const options = {
1431
1430
customProperties : {
1432
- red : 255 ,
1433
- green : 96 ,
1434
- blue : 16 ,
1435
- rgb : 'var(--red), var(--green), var(--blue)' ,
1436
- alpha : 0.42
1431
+ '-- red' : 255 ,
1432
+ '-- green' : 96 ,
1433
+ '-- blue' : 16 ,
1434
+ '-- rgb' : 'var(--red), var(--green), var(--blue)' ,
1435
+ '-- alpha' : 0.42
1437
1436
}
1438
1437
} ;
1439
1438
expect (
@@ -1447,11 +1446,11 @@ describe('properties: custom property', () => {
1447
1446
test ( 'textShadow with nested/multiple vars' , ( ) => {
1448
1447
const options = {
1449
1448
customProperties : {
1450
- height : '20px' ,
1451
- width : '10px' ,
1452
- size : 'var(--width) var(--height)' ,
1453
- radius : '30px' ,
1454
- red : 'red'
1449
+ '-- height' : '20px' ,
1450
+ '-- width' : '10px' ,
1451
+ '-- size' : 'var(--width) var(--height)' ,
1452
+ '-- radius' : '30px' ,
1453
+ '-- red' : 'red'
1455
1454
}
1456
1455
} ;
1457
1456
const styles = css . create ( {
@@ -1474,10 +1473,10 @@ describe('properties: custom property', () => {
1474
1473
test ( 'transform with nested/multiple vars' , ( ) => {
1475
1474
const options = {
1476
1475
customProperties : {
1477
- distance : 20 ,
1478
- angle : '45deg' ,
1479
- translateX : 'translateX(var(--distance))' ,
1480
- rotateX : 'rotateX(var(--angle))'
1476
+ '-- distance' : 20 ,
1477
+ '-- angle' : '45deg' ,
1478
+ '-- translateX' : 'translateX(var(--distance))' ,
1479
+ '-- rotateX' : 'rotateX(var(--angle))'
1481
1480
}
1482
1481
} ;
1483
1482
const styles = css . create ( {
@@ -1495,7 +1494,7 @@ describe('properties: custom property', () => {
1495
1494
test ( 'css variable declaration inside a media query' , ( ) => {
1496
1495
const options = {
1497
1496
customProperties : {
1498
- example : '42px'
1497
+ '-- example' : '42px'
1499
1498
} ,
1500
1499
viewportWidth : 450
1501
1500
} ;
0 commit comments