Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/tailwindcss/src/candidate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,14 @@ it('should not parse compound group with a non-compoundable variant', () => {
expect(run('group-*:flex', { utilities, variants })).toMatchInlineSnapshot(`[]`)
})

it('empty data types are invalid', () => {
let utilities = new Utilities()
utilities.functional('bg', () => [])
let variants = new Variants()

expect(run('bg-[:foo]', { utilities, variants })).toMatchInlineSnapshot(`[]`)
})

it('should parse a variant containing an arbitrary string with unbalanced parens, brackets, curlies and other quotes', () => {
let utilities = new Utilities()
utilities.static('flex', () => [])
Expand Down
4 changes: 3 additions & 1 deletion packages/tailwindcss/src/candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ export function* parseCandidate(input: string, designSystem: DesignSystem): Iter
if (!isValidArbitrary(arbitraryValue)) continue

// Extract an explicit typehint if present, e.g. `bg-[color:var(--my-var)])`
let typehint = ''
let typehint: string | null = null
for (let i = 0; i < arbitraryValue.length; i++) {
let code = arbitraryValue.charCodeAt(i)

Expand All @@ -580,6 +580,8 @@ export function* parseCandidate(input: string, designSystem: DesignSystem): Iter
continue
}

if (typehint === '') continue

candidate.value = {
kind: 'arbitrary',
dataType: typehint || null,
Expand Down