Skip to content

charlie: align Conditional/Raw rendering with main #380

@charliecreates

Description

@charliecreates

Target branch
All PRs must branch from next/v3 and target base next/v3 (not main).

Context
In the reconciliation report for #379, next/v3 is missing the post-merge-base main work that fixed Conditional comment correctness and Raw nesting/duplication. Today next/v3’s Conditional renders conditional comments directly (and uses the old <![endif]--> closer), while main has a more robust marker + rehype-plugin approach with <![endif]/--> and explicit no-dup tests.

Scope (files/areas)

  • packages/jsx-email/src/components/conditional.tsx
  • packages/jsx-email/src/components/head.tsx
  • packages/jsx-email/src/renderer/render.ts
  • packages/jsx-email/src/renderer/raw.ts
  • (add) packages/jsx-email/src/renderer/conditional.ts
  • (tests) packages/jsx-email/test/**conditional* (+ snapshots under .snapshots/)

Tasks

  1. Port main’s Conditional “marker element” approach into next/v3:
    • Render a jsx-email-cond custom element with data-mso / data-expression / data-head markers.
    • Remove the Suspense + dangerouslySetInnerHTML conditional-comment string generation.
  2. Port main’s conditional rehype plugin into next/v3 (new file packages/jsx-email/src/renderer/conditional.ts).
  3. Update the render pipeline to ensure:
    • Raw hoisting happens before conditional processing.
    • Conditional comments always close with <![endif]/-->.
  4. Update Head to match main’s current behavior:
    • Use <Conditional head mso> with <Raw content="<xml>…</xml>" /> inside.
  5. Port the targeted correctness tests from main into next/v3:
    • packages/jsx-email/test/conditional-endif-closer.test.tsx
    • packages/jsx-email/test/conditional-raw-nodup.test.tsx
    • packages/jsx-email/test/conditional-raw.test.tsx
    • Keep snapshot updates minimal (only intentional markup changes).

Acceptance criteria (done when)

  • Conditional output in next/v3 matches main’s closer semantics (<![endif]/-->) for both mso and expression paths.
  • Nesting <Raw> inside <Conditional> does not duplicate the raw payload or emit it outside the conditional block.
  • jsx-email unit tests pass on next/v3 with FORCE_COLOR=1.

Verification

# Unit tests (match CI color behavior)
$ FORCE_COLOR=1 moon jsx-email:test

# CLI tests (optional but recommended when touching render output)
$ FORCE_COLOR=1 moon test-cli:test.run

Refs #379.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions