@@ -262,11 +262,58 @@ it('should not convert escaped underscores with spaces', () => {
262
262
} )
263
263
} )
264
264
265
- it ( 'should warn and not generate if arbitrary values are ambiguous' , ( ) => {
266
- // If we don't protect against this, then `bg-[200px_100px]` would both
267
- // generate the background-size as well as the background-position utilities.
265
+ it ( 'should pick the fallback plugin when arbitrary values collide' , ( ) => {
268
266
let config = {
269
- content : [ { raw : html `<div class= "bg-[200px_100px]" > </ div> ` } ] ,
267
+ content : [
268
+ {
269
+ raw : html `
270
+ <div>
271
+ <!- - Background color - - >
272
+ <div class= "bg-[var(--unknown)]" > </ div>
273
+ <!- - Background size - - >
274
+ <div class= "bg-[200px_100px]" > </ div>
275
+ </ div>
276
+ ` ,
277
+ } ,
278
+ ] ,
279
+ }
280
+
281
+ return run ( '@tailwind utilities' , config ) . then ( ( result ) => {
282
+ return expect ( result . css ) . toMatchFormattedCss ( css `
283
+ .bg-\[var\(--unknown \)\] {
284
+ background-color : var (--unknown );
285
+ }
286
+
287
+ .bg-\[200px_100px \] {
288
+ background-size : 200px 100px ;
289
+ }
290
+ ` )
291
+ } )
292
+ } )
293
+
294
+ it ( 'should pick the fallback plugin when arbitrary values collide and can not be inferred' , ( ) => {
295
+ let config = {
296
+ content : [ { raw : html `<div class= "bg-[var(--tw-unknown)]" > </ div> ` } ] ,
297
+ }
298
+
299
+ return run ( '@tailwind utilities' , config ) . then ( ( result ) => {
300
+ return expect ( result . css ) . toMatchFormattedCss ( css `
301
+ .bg-\[var\(--tw-unknown \)\] {
302
+ background-color : var (--tw-unknown );
303
+ }
304
+ ` )
305
+ } )
306
+ } )
307
+
308
+ it ( 'should warn and not generate if arbitrary values are ambiguous (without fallback)' , ( ) => {
309
+ let config = {
310
+ content : [ { raw : html `<div class= "foo-[200px_100px]" > </ div> ` } ] ,
311
+ plugins : [
312
+ function ( { matchUtilities } ) {
313
+ matchUtilities ( { foo : ( value ) => ( { value } ) } , { type : [ 'position' ] } )
314
+ matchUtilities ( { foo : ( value ) => ( { value } ) } , { type : [ 'length' ] } )
315
+ } ,
316
+ ] ,
270
317
}
271
318
272
319
return run ( '@tailwind utilities' , config ) . then ( ( result ) => {
0 commit comments