Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-loops-render.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@qwik.dev/core': patch
---

fix: render nested Each components on the server
4 changes: 2 additions & 2 deletions packages/docs/src/repl/bundler/repl-bundler-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async function performBundle(message: BundleMessage): Promise<ReplResult> {
debug,
srcInputs,
entryStrategy,
experimental: ['suspense'],
experimental: ['each', 'show', 'suspense'],
manifestOutput: (m: any) => {
result.manifest = m;
},
Expand Down Expand Up @@ -233,7 +233,7 @@ async function performBundle(message: BundleMessage): Promise<ReplResult> {
debug,
srcInputs,
entryStrategy,
experimental: ['suspense'],
experimental: ['each', 'show', 'suspense'],
}),
replResolver(deps, { srcInputs, buildMode, replId }, 'ssr'),
replMinify(buildMode),
Expand Down
4 changes: 2 additions & 2 deletions packages/qwik/src/core/control-flow/each.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export const eachCmpTask = async ({ track }: TaskCtx) => {
const context = tryGetInvokeContext()!;
const host = context.$hostElement$!;
const container = context.$container$!;
markVNodeDirty(container, host, ChoreBits.RECONCILE);
const renderPromise = markVNodeDirty(container, host, ChoreBits.RECONCILE);
const isSsr = qTest ? isServerPlatform() : isServer;
if (isSsr) {
await container.$renderPromise$;
await renderPromise;
}
};

Expand Down
5 changes: 3 additions & 2 deletions packages/qwik/src/core/shared/vnode/vnode-dirty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { isServerPlatform } from '../platform/platform';
import type { Container } from '../types';
import { throwErrorAndStop } from '../utils/log';
import { isPromise } from '../utils/promises';
import type { ValueOrPromise } from '../utils/types';
import {
getNearestCursorBoundary,
getOwnCursorBoundary,
Expand Down Expand Up @@ -136,7 +137,7 @@ export function markVNodeDirty(
vNode: VNode | ISsrNode,
bits: ChoreBits,
cursorRoot: VNode | null = null
): void {
): ValueOrPromise<void> {
const prevDirty = vNode.dirty;
vNode.dirty |= bits;
if (isSsrNodeGuard(vNode)) {
Expand All @@ -146,7 +147,7 @@ export function markVNodeDirty(
? container.$renderPromise$.then(() => result)
: result;
}
return;
return result;
}
const isRealDirty = bits & ChoreBits.DIRTY_MASK;
// If already dirty, no need to propagate again
Expand Down
33 changes: 33 additions & 0 deletions packages/qwik/src/core/tests/each.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,39 @@ describe.each([
);
});

it('should render nested each items', async () => {
const Cmp = component$(() => {
return (
<div id="loop">
<Each
items={[
['a', 'b'],
['c', 'd'],
]}
key$={(_, index) => String(index)}
item$={(items) => (
<Each
items={items}
key$={(_, index) => String(index)}
item$={(item) => <span>{item}</span>}
/>
)}
/>
</div>
);
});

const { document } = await render(<Cmp />, { debug });
await expect(document.getElementById('loop')).toMatchDOM(
<div id="loop">
<span>a</span>
<span>b</span>
<span>c</span>
<span>d</span>
</div>
);
});

it('should render long each item', async () => {
const Cmp = component$(() => {
return (
Expand Down
Loading