Skip to content

test(et): drop generic host render fallback#2552

Merged
Yradex merged 1 commit into
lynx-family:mainfrom
Yradex:slice/element-template/01
May 6, 2026
Merged

test(et): drop generic host render fallback#2552
Yradex merged 1 commit into
lynx-family:mainfrom
Yradex:slice/element-template/01

Conversation

@Yradex
Copy link
Copy Markdown
Collaborator

@Yradex Yradex commented Apr 30, 2026

Summary by CodeRabbit

  • Tests

    • Expanded test suite for rendering functionality with improved coverage of edge cases and error conditions.
  • Bug Fixes

    • Enhanced development-time error detection for invalid rendering scenarios.
    • Improved consistency in rendering behavior across different vnode types.

Overview

This removes the Element Template main-thread renderer generic host-vnode fallback. The renderer now accepts compiled ET host nodes only; development builds fail fast when a plain host vnode reaches this path, while production keeps the framework-internal invariant out of the hot path.

Key Points

  • Deletes the generic host materialization path from render-to-opcodes.
  • Keeps compiled ET host rendering for _et_*, dynamic-entry _et_*, and raw-text template hosts.
  • Updates ET render opcode tests so they no longer rely on rendering plain view or text hosts.
  • Preserves handling for non-renderable function outputs.

Validation

  • pnpm run test:et
  • pnpm test

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

⚠️ No Changeset found

Latest commit: d46a9bc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

📝 Walkthrough

Walkthrough

This PR enforces compiled Element Template paths for string host vnode rendering, removing fallback rendering for uncompiled vnodes and introducing dev-mode errors for invalid vnode shapes. Test expectations are updated to match primitive outputs and raw text rendering semantics.

Changes

String Host VNode Rendering & Validation

Layer / File(s) Summary
Core Implementation
packages/react/runtime/src/element-template/runtime/render/render-to-opcodes.ts
renderStringHostVNode now requires compiled ET host types in dev mode; throws on plain host or invalid vnodes. Fallback path to renderGenericHostVNode is removed.
Test Imports & Setup
packages/react/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx (lines 17–31)
Imports DIFFED and PARENT constants. Updates slot array test to use primitive string markers instead of text vnodes.
Error Path Tests
packages/react/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx (lines 62–99)
New tests verify function value filtering, plain host vnode errors, and invalid vnode errors. Adds DIFFED hook cleanup validation on error paths.
Rendering Output Updates
packages/react/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx (lines 111–245)
Fragment, derived state, context, suspense, hook, and unmount tests are updated to return raw primitives and strings instead of wrapped text vnodes. Direct Fragment invocation replaces h.Fragment patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • HuJean
  • hzy

Poem

🐰 The paths are cleaned, the types now strict,
No fallbacks loose—each route's explicit.
Raw strings bloom where vnodes hid their face,
And errors guard the sacred ET space.
A tidy render, primitives laid bare! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing the generic host render fallback in Element Template rendering, which is the primary focus of both the implementation and test changes.
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 Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 30, 2026

Merging this PR will degrade performance by 14.67%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 79 untouched benchmarks
⏩ 26 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
008-many-use-state-destroyBackground 9.5 ms 8 ms +18.85%
transform 1000 view elements 40 ms 46.9 ms -14.67%

Comparing Yradex:slice/element-template/01 (d46a9bc) with main (f706c3a)

Open in CodSpeed

Footnotes

  1. 26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 30, 2026

React MTF Example

#892 Bundle Size — 196.68KiB (0%).

d46a9bc(current) vs f706c3a main#884(baseline)

Bundle metrics  no changes
                 Current
#892
     Baseline
#884
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 174 174
No change  Duplicate Modules 66 66
No change  Duplicate Code 44.05% 44.05%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#892
     Baseline
#884
No change  IMG 111.23KiB 111.23KiB
No change  Other 85.45KiB 85.45KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 30, 2026

React Example

#7760 Bundle Size — 225.52KiB (0%).

d46a9bc(current) vs f706c3a main#7752(baseline)

Bundle metrics  no changes
                 Current
#7760
     Baseline
#7752
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 180 180
No change  Duplicate Modules 69 69
No change  Duplicate Code 44.54% 44.54%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7760
     Baseline
#7752
No change  IMG 145.76KiB 145.76KiB
No change  Other 79.77KiB 79.77KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 30, 2026

Web Explorer

#9333 Bundle Size — 900.03KiB (0%).

d46a9bc(current) vs f706c3a main#9325(baseline)

Bundle metrics  Change 1 change
                 Current
#9333
     Baseline
#9325
No change  Initial JS 44.46KiB 44.46KiB
No change  Initial CSS 2.22KiB 2.22KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 9 9
No change  Assets 11 11
Change  Modules 230(+0.44%) 229
No change  Duplicate Modules 11 11
No change  Duplicate Code 27.28% 27.28%
No change  Packages 10 10
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#9333
     Baseline
#9325
No change  JS 495.9KiB 495.9KiB
No change  Other 401.92KiB 401.92KiB
No change  CSS 2.22KiB 2.22KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 30, 2026

React External

#875 Bundle Size — 680.82KiB (0%).

d46a9bc(current) vs f706c3a main#867(baseline)

Bundle metrics  no changes
                 Current
#875
     Baseline
#867
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#875
     Baseline
#867
No change  Other 680.82KiB 680.82KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 30, 2026

React Example (Element Template)

#10 Bundle Size — 198.09KiB (-0.26%).

c986b9a(current) vs 7abb0a9 main#4(baseline)

Bundle metrics  Change 3 changes
                 Current
#10
     Baseline
#4
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 26.61% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 78(-2.5%) 80
No change  Duplicate Modules 23 23
Change  Duplicate Code 40.59%(-0.22%) 40.68%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#10
     Baseline
#4
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 52.34KiB (-0.98%) 52.85KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/react/runtime/src/element-template/runtime/render/render-to-opcodes.ts`:
- Around line 268-271: The new dev-only throws in render-to-opcodes (the checks
using isCompiledEtHostType in the main-thread renderer) happen after
_renderToString() has attached vnode[PARENT] and fired beforeDiff/beforeDiff2,
so ensure you call cleanupVNode(vnode) before throwing to run
afterDiff/unmount/parent reset; update both offending throw sites (the one
around the isCompiledEtHostType check at the shown location and the similar one
at the later 336–338 location) to invoke cleanupVNode(vnode) first (keeping the
throw behavior intact) so cleanup always runs on the fail-fast paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a56482b9-3f5d-41fc-b9f1-3b2ad83810bf

📥 Commits

Reviewing files that changed from the base of the PR and between 08aa667 and c986b9a.

📒 Files selected for processing (2)
  • packages/react/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx
  • packages/react/runtime/src/element-template/runtime/render/render-to-opcodes.ts

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 3, 2026

React Example (Element Template)

#22 Bundle Size — 198.09KiB (-0.26%).

c986b9a(current) vs f706c3a main#20(baseline)

Bundle metrics  Change 3 changes
                 Current
#22
     Baseline
#20
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 26.61% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 78(+1.3%) 77
No change  Duplicate Modules 23 23
Change  Duplicate Code 40.59%(+0.15%) 40.53%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#22
     Baseline
#20
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 52.34KiB (-0.98%) 52.85KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 3, 2026

React Example (Element Template)

#23 Bundle Size — 198.09KiB (-0.26%).

c986b9a(current) vs f706c3a main#20(baseline)

Bundle metrics  Change 3 changes
                 Current
#23
     Baseline
#20
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 26.61% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 78(+1.3%) 77
No change  Duplicate Modules 23 23
Change  Duplicate Code 40.59%(+0.15%) 40.53%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#23
     Baseline
#20
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 52.34KiB (-0.98%) 52.85KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@Yradex Yradex force-pushed the slice/element-template/01 branch 2 times, most recently from aaff512 to b92dac8 Compare May 3, 2026 17:07
@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 3, 2026

React Example (Element Template)

#24 Bundle Size — 198.09KiB (-0.26%).

b92dac8(current) vs f706c3a main#20(baseline)

Bundle metrics  Change 3 changes
                 Current
#24
     Baseline
#20
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 26.61% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 79(+2.6%) 77
No change  Duplicate Modules 23 23
Change  Duplicate Code 40.55%(+0.05%) 40.53%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#24
     Baseline
#20
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 52.34KiB (-0.98%) 52.85KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 3, 2026

React Example (Element Template)

#25 Bundle Size — 198.09KiB (-0.26%).

b92dac8(current) vs f706c3a main#20(baseline)

Bundle metrics  Change 3 changes
                 Current
#25
     Baseline
#20
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 26.61% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 79(+2.6%) 77
No change  Duplicate Modules 23 23
Change  Duplicate Code 40.55%(+0.05%) 40.53%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#25
     Baseline
#20
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 52.34KiB (-0.98%) 52.85KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@Yradex Yradex force-pushed the slice/element-template/01 branch from b92dac8 to d46a9bc Compare May 3, 2026 17:48
@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 3, 2026

React Example (Element Template)

#26 Bundle Size — 198.09KiB (-0.26%).

d46a9bc(current) vs f706c3a main#20(baseline)

Bundle metrics  Change 3 changes
                 Current
#26
     Baseline
#20
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 26.61% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 78(+1.3%) 77
No change  Duplicate Modules 23 23
Change  Duplicate Code 40.57%(+0.1%) 40.53%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#26
     Baseline
#20
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 52.34KiB (-0.98%) 52.85KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 3, 2026

React Example (Element Template)

#28 Bundle Size — 198.09KiB (-0.26%).

d46a9bc(current) vs f706c3a main#20(baseline)

Bundle metrics  Change 3 changes
                 Current
#28
     Baseline
#20
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 26.61% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 78(+1.3%) 77
No change  Duplicate Modules 23 23
Change  Duplicate Code 40.57%(+0.1%) 40.53%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#28
     Baseline
#20
No change  IMG 145.76KiB 145.76KiB
Improvement  Other 52.34KiB (-0.98%) 52.85KiB

Bundle analysis reportBranch Yradex:slice/element-template/01Project dashboard


Generated by RelativeCIDocumentationReport issue

@Yradex Yradex marked this pull request as ready for review May 6, 2026 02:45
@Yradex Yradex requested review from HuJean and hzy as code owners May 6, 2026 02:45
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d46a9bc721

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/react/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx (1)

66-101: ⚡ Quick win

Guard dev-only invariant tests with __DEV__ checks.

These assertions target dev-only behavior, but they currently run unconditionally. Adding early guards in the tests at Line 66, Line 72, and Line 78 avoids environment-coupled failures if this suite is ever executed against a non-dev build.

Suggested patch
   it('throws in development when a plain host vnode reaches the ET render path', () => {
+    if (!__DEV__) return;
     expect(() => renderToString(h('view', null))).toThrow(
       'Element Template main-thread renderer received an uncompiled host vnode: view',
     );
   });

   it('throws in development when an invalid vnode reaches the ET render path', () => {
+    if (!__DEV__) return;
     expect(() => renderToString({ type: null, props: {} })).toThrow(
       'Element Template main-thread renderer received an invalid vnode.',
     );
   });

   it('cleans vnodes before throwing development renderer invariant errors', () => {
+    if (!__DEV__) return;
     const previousDiffed = options[DIFFED];
     const cleaned = [];
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/react/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx`
around lines 66 - 101, These test cases assert dev-only invariants and must be
gated by the __DEV__ flag: wrap the three affected tests that call
renderToString(h('view', ...)), renderToString({type:null,...}) and the "cleans
vnodes..." test with early guards checking if (__DEV__) so they only run in
development; update the three "it(...)" blocks in the file to return/skip when
__DEV__ is false, preserving the existing use of renderToString, h,
options[DIFFED], DIFFED and PARENT inside the guarded blocks so the behavior and
cleanup assertions remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@packages/react/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx`:
- Around line 66-101: These test cases assert dev-only invariants and must be
gated by the __DEV__ flag: wrap the three affected tests that call
renderToString(h('view', ...)), renderToString({type:null,...}) and the "cleans
vnodes..." test with early guards checking if (__DEV__) so they only run in
development; update the three "it(...)" blocks in the file to return/skip when
__DEV__ is false, preserving the existing use of renderToString, h,
options[DIFFED], DIFFED and PARENT inside the guarded blocks so the behavior and
cleanup assertions remain unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9441ea78-60b9-4193-9fd3-196d5cbdf931

📥 Commits

Reviewing files that changed from the base of the PR and between c986b9a and d46a9bc.

📒 Files selected for processing (2)
  • packages/react/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx
  • packages/react/runtime/src/element-template/runtime/render/render-to-opcodes.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react/runtime/src/element-template/runtime/render/render-to-opcodes.ts

@Yradex Yradex merged commit 68502b7 into lynx-family:main May 6, 2026
82 of 85 checks passed
@Yradex Yradex deleted the slice/element-template/01 branch May 6, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants