mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-01-10 16:29:12 +08:00
* fix: jsx slot render unexpected #215 * test: update test
This commit is contained in:
parent
7efda55501
commit
b0fb8c0db4
@ -122,7 +122,7 @@ const transformJSXElement = (
|
|||||||
t.isCallExpression(child) && child.loc && isComponent
|
t.isCallExpression(child) && child.loc && isComponent
|
||||||
) { // the element was generated and doesn't have location information
|
) { // the element was generated and doesn't have location information
|
||||||
const slotId = path.scope.generateUidIdentifier('slot');
|
const slotId = path.scope.generateUidIdentifier('slot');
|
||||||
const scope = path.hub.getScope();
|
const scope = path.scope;
|
||||||
if (scope) {
|
if (scope) {
|
||||||
scope.push({
|
scope.push({
|
||||||
id: slotId,
|
id: slotId,
|
||||||
|
@ -570,4 +570,24 @@ describe('should support passing object slots via JSX children', () => {
|
|||||||
|
|
||||||
expect(wrapper.html()).toBe('<span>foo<!----></span>');
|
expect(wrapper.html()).toBe('<span>foo<!----></span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('single expression, array map expression', () => {
|
||||||
|
const Test = defineComponent({
|
||||||
|
setup(_, { slots }) {
|
||||||
|
return () => <span>{slots.default?.()}</span>;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = ['A', 'B', 'C'];
|
||||||
|
|
||||||
|
const wrapper = mount({
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>{data.map((item: string) => <Test><span>{item}</span></Test>)}</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.html()).toBe('<div><span><span>A</span></span><span><span>B</span></span><span><span>C</span></span></div>');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user