mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2024-11-10 09:39:14 +08:00
fix: dynamic slot flag not working
This commit is contained in:
parent
de17052e7d
commit
3a83e668f4
@ -49,11 +49,11 @@ const transformJSXSpreadAttribute = (
|
||||
mergeProps: boolean,
|
||||
args: (t.ObjectProperty | t.Expression | t.SpreadElement)[],
|
||||
) => {
|
||||
const argument = path.get('argument') as NodePath<t.ObjectExpression>;
|
||||
const { properties } = argument.node;
|
||||
const argument = path.get('argument') as NodePath<t.ObjectExpression | t.Identifier>;
|
||||
const properties = t.isObjectExpression(argument.node) ? argument.node.properties : undefined;
|
||||
if (!properties) {
|
||||
if (argument.isIdentifier()) {
|
||||
walksScope(nodePath, (argument as any).name, SlotFlags.DYNAMIC);
|
||||
walksScope(nodePath, (argument.node as t.Identifier).name, SlotFlags.DYNAMIC);
|
||||
}
|
||||
args.push(mergeProps ? argument.node : t.spreadElement(argument.node));
|
||||
} else if (mergeProps) {
|
||||
|
@ -414,37 +414,37 @@ describe('variables outside slots', () => {
|
||||
|
||||
A.inheritAttrs = false;
|
||||
|
||||
// test('internal', async () => {
|
||||
// const wrapper = mount(defineComponent({
|
||||
// data() {
|
||||
// return {
|
||||
// val: 0,
|
||||
// };
|
||||
// },
|
||||
// methods: {
|
||||
// inc() {
|
||||
// this.val += 1;
|
||||
// },
|
||||
// },
|
||||
// render() {
|
||||
// const attrs = {
|
||||
// innerHTML: `${this.val}`,
|
||||
// };
|
||||
// return (
|
||||
// <A inc={this.inc}>
|
||||
// <div>
|
||||
// <textarea id="textarea" {...attrs} />
|
||||
// </div>
|
||||
// <button id="button" onClick={this.inc}>+1</button>
|
||||
// </A>
|
||||
// );
|
||||
// },
|
||||
// }));
|
||||
test('internal', async () => {
|
||||
const wrapper = mount(defineComponent({
|
||||
data() {
|
||||
return {
|
||||
val: 0,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
inc() {
|
||||
this.val += 1;
|
||||
},
|
||||
},
|
||||
render() {
|
||||
const attrs = {
|
||||
innerHTML: `${this.val}`,
|
||||
};
|
||||
return (
|
||||
<A inc={this.inc}>
|
||||
<div>
|
||||
<textarea id="textarea" {...attrs} />
|
||||
</div>
|
||||
<button id="button" onClick={this.inc}>+1</button>
|
||||
</A>
|
||||
);
|
||||
},
|
||||
}));
|
||||
|
||||
// expect(wrapper.get('#textarea').element.innerHTML).toBe('0');
|
||||
// await wrapper.get('#button').trigger('click');
|
||||
// expect(wrapper.get('#textarea').element.innerHTML).toBe('1');
|
||||
// });
|
||||
expect(wrapper.get('#textarea').element.innerHTML).toBe('0');
|
||||
await wrapper.get('#button').trigger('click');
|
||||
expect(wrapper.get('#textarea').element.innerHTML).toBe('1');
|
||||
});
|
||||
|
||||
test('forwarded', async () => {
|
||||
const wrapper = mount({
|
||||
|
Loading…
Reference in New Issue
Block a user