Skip to content

Commit df3051c

Browse files
committed
fix: normalize constant class and style
1 parent ba0583c commit df3051c

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

packages/babel-plugin-jsx/src/transform-vue-jsx.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,20 +337,28 @@ const buildProps = (path: NodePath<t.JSXElement>, state: State) => {
337337
if (
338338
!t.isObjectProperty(property) ||
339339
!t.isStringLiteral(property.key) ||
340-
!t.isExpression(property.value) ||
341-
isConstant(property.value)
342-
)
340+
!t.isExpression(property.value)
341+
) {
343342
continue;
343+
}
344+
// TODO: if isConstant, pre-normalize class and style during build
344345
if (property.key.value === 'class') {
345-
property.value = t.callExpression(
346-
createIdentifier(state, 'normalizeClass'),
347-
[property.value]
348-
);
346+
if (!t.isStringLiteral(property.value)) {
347+
property.value = t.callExpression(
348+
createIdentifier(state, 'normalizeClass'),
349+
[property.value]
350+
);
351+
}
349352
} else if (property.key.value === 'style') {
350-
property.value = t.callExpression(
351-
createIdentifier(state, 'normalizeStyle'),
352-
[property.value]
353-
);
353+
if (
354+
!t.isStringLiteral(property.value) &&
355+
!t.isObjectExpression(property.value)
356+
) {
357+
property.value = t.callExpression(
358+
createIdentifier(state, 'normalizeStyle'),
359+
[property.value]
360+
);
361+
}
354362
}
355363
}
356364
}

0 commit comments

Comments
 (0)