mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2024-11-10 09:39:14 +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),
|
||||
));
|
||||
}
|
||||
mergeArgs.push(t.objectExpression(dedupeProperties(properties)));
|
||||
properties = [];
|
||||
} else {
|
||||
if (properties.length) {
|
||||
mergeArgs.push(t.objectExpression(dedupeProperties(properties)));
|
||||
properties = [];
|
||||
}
|
||||
|
||||
// JSXSpreadAttribute
|
||||
hasDynamicKeys = true;
|
||||
transformJSXSpreadAttribute(
|
||||
@ -313,6 +316,9 @@ const buildProps = (path: NodePath<t.JSXElement>, state: State) => {
|
||||
let propsExpression: t.Expression | t.ObjectProperty | t.Literal = t.nullLiteral();
|
||||
|
||||
if (mergeArgs.length) {
|
||||
if (properties.length) {
|
||||
mergeArgs.push(t.objectExpression(dedupeProperties(properties)));
|
||||
}
|
||||
if (mergeArgs.length > 1) {
|
||||
propsExpression = t.callExpression(
|
||||
createIdentifier(state, 'mergeProps'),
|
||||
@ -322,6 +328,8 @@ const buildProps = (path: NodePath<t.JSXElement>, state: State) => {
|
||||
// single no need for a mergeProps call
|
||||
propsExpression = mergeArgs[0];
|
||||
}
|
||||
} else if (properties.length) {
|
||||
propsExpression = t.objectExpression(dedupeProperties(properties));
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user