Skip to content

Commit a36a963

Browse files
authored
Merge pull request #8188 from QwikDev/v2-jsx-split-children
fix: removing children from var props
2 parents dd133bc + 9627e22 commit a36a963

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

.changeset/nasty-views-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik.dev/core': patch
3+
---
4+
5+
fix: removing children from var props

packages/qwik/src/core/shared/jsx/jsx-internal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ export const _jsxSplit = <T extends string | FunctionComponent<any>>(
6666
for (const k in varProps) {
6767
if (k === 'children') {
6868
children ||= varProps.children as JSXChildren;
69-
varProps.children = undefined;
69+
delete varProps.children;
7070
} else if (k === 'key') {
7171
key ||= varProps.key as string;
72-
varProps.key = undefined;
72+
delete varProps.key;
7373
} else if (constProps && k in constProps) {
74-
varProps[k] = undefined;
74+
delete varProps[k];
7575
}
7676
}
7777
}

packages/qwik/src/core/tests/inline-component.spec.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Fragment as Signal,
77
Slot,
88
component$,
9+
jsx,
910
useSignal,
1011
useStore,
1112
useVisibleTask$,
@@ -41,6 +42,16 @@ const ChildInline = () => {
4142
return <div>Child inline</div>;
4243
};
4344

45+
const OwnKeys = {
46+
HAccordionRoot: (props: any) => {
47+
return jsx('div', props);
48+
},
49+
Root: (props: any) => <OwnKeys.HAccordionRoot {...props} accordionItemComponent={OwnKeys.Item} />,
50+
Item: component$(() => {
51+
return <></>;
52+
}),
53+
};
54+
4455
describe.each([
4556
{ render: ssrRenderToDom }, //
4657
{ render: domRender }, //
@@ -732,4 +743,16 @@ describe.each([
732743
</InlineComponent>
733744
);
734745
});
746+
747+
it('should remove children from varProps and not throw', async () => {
748+
const Cmp = component$(() => {
749+
return (
750+
<OwnKeys.Root class="w-96">
751+
<OwnKeys.Item />
752+
</OwnKeys.Root>
753+
);
754+
});
755+
756+
await expect(render(<Cmp />, { debug })).resolves.not.toThrow();
757+
});
735758
});

0 commit comments

Comments
 (0)