From 3a95d94f1332a08aab75f188b5a480f0ba75859a Mon Sep 17 00:00:00 2001 From: Varixo Date: Mon, 6 Jan 2025 13:30:27 +0100 Subject: [PATCH] fix: projection siblings serialization --- .changeset/friendly-sloths-return.md | 5 ++ .../qwik/src/core/tests/projection.spec.tsx | 90 +++++++++++++------ packages/qwik/src/server/ssr-container.ts | 6 +- 3 files changed, 71 insertions(+), 30 deletions(-) create mode 100644 .changeset/friendly-sloths-return.md diff --git a/.changeset/friendly-sloths-return.md b/.changeset/friendly-sloths-return.md new file mode 100644 index 00000000000..f3cda8ab3a2 --- /dev/null +++ b/.changeset/friendly-sloths-return.md @@ -0,0 +1,5 @@ +--- +'@qwik.dev/core': patch +--- + +fix: projection siblings serialization diff --git a/packages/qwik/src/core/tests/projection.spec.tsx b/packages/qwik/src/core/tests/projection.spec.tsx index 75962867266..1420a229f6c 100644 --- a/packages/qwik/src/core/tests/projection.spec.tsx +++ b/packages/qwik/src/core/tests/projection.spec.tsx @@ -21,7 +21,7 @@ import { import { domRender, ssrRenderToDom, trigger } from '@qwik.dev/core/testing'; import { cleanupAttrs } from 'packages/qwik/src/testing/element-fixture'; import { beforeEach, describe, expect, it } from 'vitest'; -import { vnode_getNextSibling } from '../client/vnode'; +import { vnode_getNextSibling, vnode_getProp, vnode_locate } from '../client/vnode'; import { HTML_NS, SVG_NS } from '../shared/utils/markers'; const DEBUG = false; @@ -101,9 +101,9 @@ describe.each([ }); const { vNode } = await render(, { debug: DEBUG }); expect(vNode).toMatchVDOM( - - - default-value + + + default-value ); @@ -117,9 +117,9 @@ describe.each([ }); const { vNode } = await render(, { debug: DEBUG }); expect(vNode).toMatchVDOM( - - - projection-value + + + projection-value ); @@ -951,12 +951,12 @@ describe.each([ const { vNode } = await render(, { debug: DEBUG }); expect(vNode).toMatchVDOM( - - - + + +
- - + + START @@ -993,12 +993,12 @@ describe.each([ const { vNode } = await render(, { debug: DEBUG }); expect(vNode).toMatchVDOM( - - - + + +
- - + + START @@ -1105,16 +1105,16 @@ describe.each([ const { vNode } = await render(, { debug: DEBUG }); expect(vNode).toMatchVDOM( - - - - - - - + + + + + + + - - {'INSIDE THING'} + + {'INSIDE THING'} @@ -1986,6 +1986,44 @@ describe.each([ }); }); + it('should serialize all component props next to projection', async () => { + const InnerCmp = component$(() => { + return ; + }); + + const Cmp = component$(() => { + return ( +
+ + {/* ^ This component */} +
+
+ +
+ ); + }); + + const Parent = component$(() => { + const counter = useSignal(0); + return ( + <> + +
+
+ + + ); + }); + + const { container } = await render(, { debug: DEBUG }); + + if (ssrRenderToDom === render) { + const CmpVNode = vnode_locate(container.rootVNode, '4A'); + const renderProp = vnode_getProp(CmpVNode, 'q:renderFn', null); + expect(renderProp).not.toBeNull(); + } + }); + describe('regression', () => { it('#1630', async () => { const Child = component$(() => CHILD); diff --git a/packages/qwik/src/server/ssr-container.ts b/packages/qwik/src/server/ssr-container.ts index 89b8af915ca..48a3d7defb7 100644 --- a/packages/qwik/src/server/ssr-container.ts +++ b/packages/qwik/src/server/ssr-container.ts @@ -458,12 +458,10 @@ class SSRContainer extends _SharedContainer implements ISSRContainer { openProjection(attrs: SsrAttrs) { this.openFragment(attrs); - const vNode = this.currentElementFrame?.vNodeData; - if (vNode) { - vNode[0] |= VNodeDataFlag.SERIALIZE; - } const componentFrame = this.getComponentFrame(); if (componentFrame) { + // TODO: we should probably serialize only projection VNode + this.serializationCtx.$addRoot$(componentFrame.componentNode); componentFrame.projectionDepth++; } }