Skip to content

Commit

Permalink
fix: tailwind prop with equal sigh (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored May 3, 2024
1 parent 14df889 commit 075e4c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function tokenize(code) {
}
}
// `=` in property=<value>
if (next === '=') {
if (next === '=' && !inStringContent()) {
const prop = current ? (current + curr) : curr
if (isIdentifier(prop)) {
current = prop
Expand Down
15 changes: 15 additions & 0 deletions test/ast.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ describe('jsx', () => {
['/>', 'sign'],
])
})

it('should handle tailwind properties well', () => {
const code = `<div className="data-[layout=grid]:grid" />`
const tokens = tokenize(code)
expect(extractTokenArray(tokens)).toEqual([
['<', 'sign'],
['div', 'entity'],
['className', 'property'],
['=', 'sign'],
['"', 'string'],
['data-[layout=grid]:grid', 'string'],
['"', 'string'],
['/>', 'sign'],
])
})
})

describe('comments', () => {
Expand Down

0 comments on commit 075e4c0

Please sign in to comment.