Skip to content

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Sep 3, 2025

Avoid creating doCreateVNode each call.

Summary by CodeRabbit

  • Refactor

    • Simplified rendering helper control flow to a single consistent path per branch, improving maintainability.
    • Centralized VNode creation and streamlined argument handling for props and children while keeping the public API unchanged.
  • Reliability

    • Ensures consistent behavior for props-only, single-child, and multiple-child call patterns.
    • Reduces edge-case inconsistencies in how single-child values are arrayified and interpreted.
  • Developer Impact

    • No changes to exported function signatures; existing usage continues to work as before.

Copy link

coderabbitai bot commented Sep 3, 2025

Walkthrough

Refactors h() to use a top-level try/finally that disables and re-enables block tracking around all logic. Removes the internal doCreateVNode helper and routes all branches to direct createVNode calls. Adjusts argument handling for 2+ arguments to consistently derive props and children without altering the public API.

Changes

Cohort / File(s) Summary
h() control-flow refactor
packages/runtime-core/src/h.ts
Removed internal doCreateVNode closure. Added top-level try/finally in h() to manage block tracking. Centralized createVNode invocation across all branches. Refined args handling: distinguish props-only vs. single-vnode child for l === 2; compute children from extra args for l > 2 (arrayify single vnode, slice for many).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Caller
  participant H as h()
  participant BT as BlockTracking
  participant V as createVNode

  C->>H: h(type, propsOrChildren?, ...children)
  Note over H: Enter try/finally scope

  H->>BT: setBlockTracking(-1) (disable)
  alt l === 2
    alt propsOrChildren is array
      H->>V: createVNode(type, null, propsOrChildren)
    else propsOrChildren is object (not array)
      alt single vnode child (no props)
        H->>V: createVNode(type, null, [propsOrChildren])
      else props-only
        H->>V: createVNode(type, propsOrChildren)
      end
    else primitive/text child
      H->>V: createVNode(type, null, propsOrChildren)
    end
  else l > 2
    Note over H: Derive children from extra args\n- 3 args: wrap single vnode in array\n- >3 args: slice to array
    H->>V: createVNode(type, propsOrChildren, children)
  else l === 1
    H->>V: createVNode(type)
  end

  V-->>H: vnode
  H->>BT: setBlockTracking(1) (re-enable)
  H-->>C: vnode
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

:cake: p2-nice-to-have

Poem

A hop, a skip, through branches I prance,
Trackers tucked away for a cleaner dance.
One call to craft nodes, tidy and light,
Props arranged, children wrapped just right.
I thump my foot—refactor delight! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 496db15 and d834f76.

📒 Files selected for processing (1)
  • packages/runtime-core/src/h.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/runtime-core/src/h.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test / e2e-test
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch edison/chore/simplifyh

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Sep 3, 2025

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB (+2 B) 38.5 kB (-10 B) 34.6 kB (+46 B)
vue.global.prod.js 159 kB (+2 B) 58.6 kB (-13 B) 52.1 kB (+39 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.6 kB 18.2 kB 16.7 kB
createApp 54.6 kB 21.3 kB 19.4 kB
createSSRApp 58.9 kB 23 kB 21 kB
defineCustomElement 59.6 kB 22.8 kB 20.9 kB
overall 68.8 kB (+2 B) 26.4 kB (-4 B) 24.2 kB (+38 B)

Copy link

pkg-pr-new bot commented Sep 3, 2025

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@13841

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@13841

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@13841

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@13841

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@13841

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@13841

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@13841

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@13841

@vue/shared

npm i https://pkg.pr.new/@vue/shared@13841

vue

npm i https://pkg.pr.new/vue@13841

@vue/compat

npm i https://pkg.pr.new/@vue/compat@13841

commit: d834f76

Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4b6cb1f and 496db15.

📒 Files selected for processing (1)
  • packages/runtime-core/src/h.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/runtime-core/src/h.ts (2)
packages/runtime-core/src/index.ts (3)
  • setBlockTracking (368-368)
  • isVNode (111-111)
  • createVNode (111-111)
packages/shared/src/general.ts (2)
  • isObject (53-54)
  • isArray (39-39)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed
🔇 Additional comments (1)
packages/runtime-core/src/h.ts (1)

205-207: Top-level try/finally for block tracking looks good

This simplifies control flow and guarantees re-enable on all return paths and throws.

Also applies to: 229-231

@edison1105 edison1105 force-pushed the edison/chore/simplifyh branch from 496db15 to d834f76 Compare September 3, 2025 01:06
@edison1105 edison1105 merged commit 75220c7 into main Sep 3, 2025
16 checks passed
@edison1105 edison1105 deleted the edison/chore/simplifyh branch September 3, 2025 01:13
9romise pushed a commit to 9romise/core that referenced this pull request Sep 23, 2025
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.

1 participant