@@ -276,6 +276,57 @@ test('test nested classFunctions', async ({ expect }) => {
276
276
expect ( classLists ) . toMatchObject ( expectedResult )
277
277
} )
278
278
279
+ test ( 'test classFunctions with tagged template literals' , async ( { expect } ) => {
280
+ const state = getTailwindSettingsForClassFunctions ( )
281
+ const classList = `pointer-events-auto relative flex bg-red-500
282
+ items-center justify-between overflow-hidden
283
+ md:min-w-[20rem] md:max-w-[37.5rem] md:py-sm pl-md py-xs pr-xs gap-sm w-full
284
+ data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)]
285
+ md:h-[calc(100%-2rem)]
286
+ data-[swipe=move]:transition-none`
287
+
288
+ const expectedResult : DocumentClassList [ ] = [
289
+ {
290
+ classList,
291
+ range : {
292
+ start : { line : 2 , character : 6 } ,
293
+ end : { line : 7 , character : 37 } ,
294
+ } ,
295
+ } ,
296
+ ]
297
+
298
+ const cnContent = `
299
+ const tagged = cn\`
300
+ ${ classList } \`
301
+ `
302
+ const cnDoc = TextDocument . create ( 'file://file.html' , 'html' , 1 , cnContent )
303
+ const cnClassLists = await findClassListsInHtmlRange ( state , cnDoc , 'html' )
304
+
305
+ console . log ( 'cnClassLists' , JSON . stringify ( cnClassLists , null , 2 ) )
306
+
307
+ expect ( cnClassLists ) . toMatchObject ( expectedResult )
308
+
309
+ const cvaContent = `
310
+ const tagged = cva\`
311
+ ${ classList } \`
312
+ `
313
+ const cvaDoc = TextDocument . create ( 'file://file.html' , 'html' , 1 , cvaContent )
314
+ const cvaClassLists = await findClassListsInHtmlRange ( state , cvaDoc , 'html' )
315
+
316
+ expect ( cvaClassLists ) . toMatchObject ( expectedResult )
317
+
318
+ // Ensure another tag name with the same layout doesn't match
319
+ const cmaContent = `
320
+ const tagged = cma\`
321
+ ${ classList } \`
322
+ `
323
+
324
+ const cmaDoc = TextDocument . create ( 'file://file.html' , 'html' , 1 , cmaContent )
325
+ const cmaClassLists = await findClassListsInHtmlRange ( state , cmaDoc , 'html' )
326
+
327
+ expect ( cmaClassLists ) . toMatchObject ( [ ] )
328
+ } )
329
+
279
330
function getTailwindSettingsForClassFunctions ( ) : Parameters < typeof findClassListsInHtmlRange > [ 0 ] {
280
331
const defaultSettings = getDefaultTailwindSettings ( )
281
332
return {
0 commit comments