Skip to content

fix(runtime-core): allow an empty dynamic component (fix #3632) - #15556

Open
JonathanYin wants to merge 1 commit into
vuejs:mainfrom
JonathanYin:fix/empty-string-dynamic-component
Open

JonathanYin wants to merge 1 commit into
vuejs:mainfrom
JonathanYin:fix/empty-string-dynamic-component

Conversation

@JonathanYin

@JonathanYin JonathanYin commented Sep 17, 2026

Copy link
Copy Markdown

closes #3632

<component :is="''"> warned about an invalid type, though it already
renders nothing, the same as :is="null".

Summary by CodeRabbit

  • Bug Fixes
    • Fixed dynamic component resolution for empty or falsy component values.
    • These values now render as empty placeholder content without triggering unnecessary warnings or lookup errors.

resolveDynamicComponent treated an empty string as a component name, so
it resolved to itself and createVNode warned about an invalid type. It
already renders a comment, matching an explicit null.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b0821b09-945f-4fd3-8b2d-e50886390fa0

📥 Commits

Reviewing files that changed from the base of the PR and between 5be58b4 and 860bb9b.

📒 Files selected for processing (2)
  • packages/runtime-core/__tests__/helpers/resolveAssets.spec.ts
  • packages/runtime-core/src/helpers/resolveAssets.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

resolveDynamicComponent now treats an empty string as falsy. The test verifies that it produces a Comment vnode without a warning.

Changes

Dynamic component resolution

Layer / File(s) Summary
Resolver guard and regression test
packages/runtime-core/src/helpers/resolveAssets.ts, packages/runtime-core/__tests__/helpers/resolveAssets.spec.ts
The resolver skips asset lookup for falsy component values. The test verifies that an empty string resolves to a Comment vnode.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 860bb

Empty dynamic components now render as comments without the prior invalid-type behavior; no actionable merge risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: allowing an empty dynamic component in runtime-core. It also identifies the related issue.
Linked Issues check ✅ Passed The change satisfies #3632. resolveDynamicComponent now treats an empty string as a falsy dynamic component and returns NULL_DYNAMIC_COMPONENT, like null. The new test creates a vnode from `reso…
Out of Scope Changes check ✅ Passed The changes stay within #3632. They modify dynamic-component resolution and add a focused regression test for the empty-string case. No unrelated behavior or files are changed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

@edison1105 edison1105 added the 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. label Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid vnode type when creating vnode

2 participants