mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-01-11 00:39:10 +08:00
fix: <A {...{ a: 1 }} />
throw error when override props
This commit is contained in:
parent
e9aa278b20
commit
f50b9e37fd
@ -56,8 +56,10 @@ const transformJSXSpreadAttribute = (
|
|||||||
walksScope(nodePath, (argument.node as t.Identifier).name, SlotFlags.DYNAMIC);
|
walksScope(nodePath, (argument.node as t.Identifier).name, SlotFlags.DYNAMIC);
|
||||||
}
|
}
|
||||||
args.push(mergeProps ? argument.node : t.spreadElement(argument.node));
|
args.push(mergeProps ? argument.node : t.spreadElement(argument.node));
|
||||||
} else {
|
} else if (mergeProps) {
|
||||||
args.push(t.objectExpression(properties));
|
args.push(t.objectExpression(properties));
|
||||||
|
} else {
|
||||||
|
args.push(...(properties as t.ObjectProperty[]));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,6 +84,10 @@ exports[`override props multiple: multiple 1`] = `
|
|||||||
createVNode(resolveComponent(\\"A\\"), {
|
createVNode(resolveComponent(\\"A\\"), {
|
||||||
\\"loading\\": true,
|
\\"loading\\": true,
|
||||||
...a,
|
...a,
|
||||||
|
b: 1,
|
||||||
|
c: {
|
||||||
|
d: 2
|
||||||
|
},
|
||||||
\\"class\\": \\"x\\",
|
\\"class\\": \\"x\\",
|
||||||
\\"style\\": x
|
\\"style\\": x
|
||||||
}, null);"
|
}, null);"
|
||||||
|
@ -149,10 +149,10 @@ tests.forEach((
|
|||||||
|
|
||||||
const overridePropsTests = [{
|
const overridePropsTests = [{
|
||||||
name: 'single',
|
name: 'single',
|
||||||
from: '<div {...a}></div>',
|
from: '<div {...a} />',
|
||||||
}, {
|
}, {
|
||||||
name: 'multiple',
|
name: 'multiple',
|
||||||
from: '<A loading {...a} class="x" style={x}></A>',
|
from: '<A loading {...a} {...{ b: 1, c: { d: 2 } }} class="x" style={x} />',
|
||||||
}];
|
}];
|
||||||
|
|
||||||
overridePropsTests.forEach((
|
overridePropsTests.forEach((
|
||||||
|
Loading…
Reference in New Issue
Block a user