Skip to content

fix: missing serialisation when child tag has its own state#3198

Merged
DylanPiercey merged 2 commits into
marko-js:mainfrom
vwong:fix/missing-serialisation
May 21, 2026
Merged

fix: missing serialisation when child tag has its own state#3198
DylanPiercey merged 2 commits into
marko-js:mainfrom
vwong:fix/missing-serialisation

Conversation

@vwong
Copy link
Copy Markdown
Contributor

@vwong vwong commented May 21, 2026

Description

#3183 introduced a regression whereby some client-only components were not serialised correctly. This fixes it.

Details

The static-content optimisation in getSectionRegisterReasons incorrectly skipped registering the section renderer when all of: downstreamReasons was specific (not true), the content section had no own serialize reasons, and neither did its parent section. This was too broad — it also fired when the downstream component had its own reactive state that caused it to unconditionally write input.content into its serialized scope, making the renderer unresolvable on the client.

The fix tightens the guard to only skip when downstreamReasons is param/input-driven (isReasonDynamic), which covers the purely iterative case from known-rest-attr-tag but not the case where the consumer's own state (e.g. <let/show>) forces the content reference into its scope regardless of what the parent passes.

Checklist:

  • I have read the CONTRIBUTING document and have signed (or will sign) the CLA.
  • I have updated/added documentation affected by my changes.
  • I have added tests to cover my changes.

vwong and others added 2 commits May 21, 2026 10:39
The static-content optimisation in getSectionRegisterReasons incorrectly
skipped registering the section renderer when all of: downstreamReasons
was specific (not true), the content section had no own serialize reasons,
and neither did its parent section. This was too broad — it also fired
when the downstream component had its own reactive state that caused it to
unconditionally write input.content into its serialized scope, making
the renderer unresolvable on the client.

The fix tightens the guard to only skip when downstreamReasons is
param/input-driven (isReasonDynamic), which covers the purely iterative
case from known-rest-attr-tag but not the case where the consumer's own
state (e.g. <let/show>) forces the content reference into its scope
regardless of what the parent passes.

Adds a fixture static-content-conditional-consumer to cover the broken
scenario: a consumer with <let/show=false> that conditionally renders
<${input.content}/> where the passed content is entirely static.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

🦋 Changeset detected

Latest commit: 2700582

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@marko/runtime-tags Patch
marko Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a8ee9064-fc7a-4fc2-bafa-20ba55aeb242

📥 Commits

Reviewing files that changed from the base of the PR and between 70846fd and 2700582.

⛔ Files ignored due to path filters (8)
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/__snapshots__/dom.bundle.debug.js is excluded by !**/__snapshots__/** and included by **
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/__snapshots__/dom.bundle.js is excluded by !**/__snapshots__/** and included by **
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/__snapshots__/html.bundle.debug.js is excluded by !**/__snapshots__/** and included by **
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/__snapshots__/html.bundle.js is excluded by !**/__snapshots__/** and included by **
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/__snapshots__/render.debug.md is excluded by !**/__snapshots__/** and included by **
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/__snapshots__/render.md is excluded by !**/__snapshots__/** and included by **
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/__snapshots__/writes.debug.html is excluded by !**/__snapshots__/** and included by **
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/__snapshots__/writes.html is excluded by !**/__snapshots__/** and included by **
📒 Files selected for processing (5)
  • .changeset/cozy-drinks-roll.md
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/tags/consumer.marko
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/template.marko
  • packages/runtime-tags/src/__tests__/fixtures/static-content-conditional-consumer/test.ts
  • packages/runtime-tags/src/translator/util/sections.ts

Walkthrough

This PR fixes content renderer registration when a downstream component has its own state. The core change modifies the condition in getSectionRegisterReasons from checking downstreamReasons !== true to using isReasonDynamic(downstreamReasons). A new test fixture validates the fix by defining a consumer component with a toggle button and conditional content placeholder that receives static content from a parent template, with test steps exercising the state transitions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: addressing missing serialization when a child tag has its own state, which matches the core change in sections.ts and the regression fix objective.
Description check ✅ Passed The description is directly related to the changeset, explaining the regression from PR #3183, the root cause in getSectionRegisterReasons, and how the fix tightens the guard condition with isReasonDynamic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.78%. Comparing base (70846fd) to head (2700582).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3198   +/-   ##
=======================================
  Coverage   92.78%   92.78%           
=======================================
  Files         372      372           
  Lines       47324    47324           
  Branches     3387     3387           
=======================================
  Hits        43911    43911           
  Misses       3380     3380           
  Partials       33       33           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DylanPiercey DylanPiercey merged commit 25a021b into marko-js:main May 21, 2026
8 checks passed
@vwong vwong deleted the fix/missing-serialisation branch May 21, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants