mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-01-11 00:39:10 +08:00
feat: merge static and dynamic class / style attributes into array
This commit is contained in:
parent
bf59811f43
commit
94b4f3aa80
@ -272,9 +272,12 @@ const buildProps = (path: NodePath<t.JSXElement>, state: State) => {
|
|||||||
attributeValue || t.booleanLiteral(true),
|
attributeValue || t.booleanLiteral(true),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (properties.length) {
|
||||||
mergeArgs.push(t.objectExpression(dedupeProperties(properties)));
|
mergeArgs.push(t.objectExpression(dedupeProperties(properties)));
|
||||||
properties = [];
|
properties = [];
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// JSXSpreadAttribute
|
// JSXSpreadAttribute
|
||||||
hasDynamicKeys = true;
|
hasDynamicKeys = true;
|
||||||
transformJSXSpreadAttribute(
|
transformJSXSpreadAttribute(
|
||||||
@ -313,6 +316,9 @@ const buildProps = (path: NodePath<t.JSXElement>, state: State) => {
|
|||||||
let propsExpression: t.Expression | t.ObjectProperty | t.Literal = t.nullLiteral();
|
let propsExpression: t.Expression | t.ObjectProperty | t.Literal = t.nullLiteral();
|
||||||
|
|
||||||
if (mergeArgs.length) {
|
if (mergeArgs.length) {
|
||||||
|
if (properties.length) {
|
||||||
|
mergeArgs.push(t.objectExpression(dedupeProperties(properties)));
|
||||||
|
}
|
||||||
if (mergeArgs.length > 1) {
|
if (mergeArgs.length > 1) {
|
||||||
propsExpression = t.callExpression(
|
propsExpression = t.callExpression(
|
||||||
createIdentifier(state, 'mergeProps'),
|
createIdentifier(state, 'mergeProps'),
|
||||||
@ -322,6 +328,8 @@ const buildProps = (path: NodePath<t.JSXElement>, state: State) => {
|
|||||||
// single no need for a mergeProps call
|
// single no need for a mergeProps call
|
||||||
propsExpression = mergeArgs[0];
|
propsExpression = mergeArgs[0];
|
||||||
}
|
}
|
||||||
|
} else if (properties.length) {
|
||||||
|
propsExpression = t.objectExpression(dedupeProperties(properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user