fix(runtime-core): disable tracking block in h function#8213
fix(runtime-core): disable tracking block in h function#8213edison1105 merged 11 commits intovuejs:mainfrom
Conversation
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
WalkthroughAdded a local wrapper in h() that disables block tracking (setBlockTracking(-1)) before calling createVNode and restores it (setBlockTracking(1)) after, replacing all createVNode calls in h(); includes a reference to issue #6913. Changes
Sequence Diagram(s)sequenceDiagram
actor C as Caller
participant H as h()
participant W as doCreateVNode
participant BT as setBlockTracking
participant CV as createVNode
C->>H: h(type, props?, children?)
H->>W: doCreateVNode(type, props, children)
W->>BT: setBlockTracking(-1)
W->>CV: createVNode(type, props, children)
CV-->>W: vnode
W->>BT: setBlockTracking(1)
W-->>H: vnode
H-->>C: vnode
note over W,BT: Temporarily disable block tracking during vnode creation (per #6913)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Assessment against linked issues
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/runtime-core/src/h.ts (1)
205-206: Optional: hoist helper to module scope to avoid per-call allocation.Defining doCreateVNode outside h() avoids creating a new closure on every call. Impact is minor since h() isn’t used by compiled templates, but it’s a cheap win.
If you prefer, lift the helper above the h() overloads and keep the same signature.
📜 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.
📒 Files selected for processing (1)
packages/runtime-core/src/h.ts(2 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)createVNode(111-111)isVNode(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). (4)
- GitHub Check: Redirect rules
- GitHub Check: Header rules
- GitHub Check: Pages changed
- GitHub Check: test / e2e-test
🔇 Additional comments (2)
packages/runtime-core/src/h.ts (2)
10-11: Import looks correct.Pulling in setBlockTracking from './vnode' is appropriate for this usage.
218-218: Consistent usage of the helper across all code paths.All createVNode calls are replaced with doCreateVNode, ensuring tracking is disabled consistently. LGTM.
Please add/confirm a regression test covering the computed + h() repro from issue #6913 (including nested h(), array children, and slot functions) to ensure no dynamicChildren/block tracking regressions.
Also applies to: 221-221, 224-224, 232-232
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|
| // Actual implementation | ||
| export function h(type: any, propsOrChildren?: any, children?: any): VNode { | ||
| // #6913 disable tracking block in h function | ||
| const doCreateVNode = (type: any, props?: any, children?: any) => { |
There was a problem hiding this comment.
Just stumbled upon this as I was reading the changelog. Is there a reason why every call to h will now (afaik) create an inline version of doCreateVNode? Can't this be created outside of the scope of calling h()?
There was a problem hiding this comment.
You are right, I made some simplifications to the h function and removed the doCreateVNode function. See #13841
close #6913
Summary by CodeRabbit
Bug Fixes
Performance
Documentation