refactor: transform to cater only for class in sfc
This commit is contained in:
parent
9bd32b6d8d
commit
524f3ad60d
|
|
@ -50,11 +50,18 @@ export function transformTwPrefix(opts: TransformOpts): CodemodPlugin {
|
||||||
if (sfcAST) {
|
if (sfcAST) {
|
||||||
traverseTemplateAST(sfcAST, {
|
traverseTemplateAST(sfcAST, {
|
||||||
enterNode(node) {
|
enterNode(node) {
|
||||||
if (node.type === 'Literal' && typeof node.value === 'string') {
|
if (node.type === 'VAttribute' && node.key.type === 'VDirectiveKey') {
|
||||||
if (!['BinaryExpression', 'Property'].includes(node.parent?.type ?? '')) {
|
if (node.key.argument?.type === 'VIdentifier') {
|
||||||
|
if (node.key.argument.name === 'class') {
|
||||||
|
const nodes = astHelpers.findAll(node, { type: 'Literal' })
|
||||||
|
nodes.forEach((node) => {
|
||||||
|
if (!['BinaryExpression', 'Property'].includes(node.parent?.type ?? '') && typeof node.value === 'string') {
|
||||||
node.value = applyPrefix(node.value, config.tailwind.prefix)
|
node.value = applyPrefix(node.value, config.tailwind.prefix)
|
||||||
transformCount++
|
transformCount++
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// handle class attribute without binding
|
// handle class attribute without binding
|
||||||
else if (node.type === 'VLiteral' && typeof node.value === 'string') {
|
else if (node.type === 'VLiteral' && typeof node.value === 'string') {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user