pref(slots): use computed to cache the result of dynamic slot function to avoid redundant calls#14176
pref(slots): use computed to cache the result of dynamic slot function to avoid redundant calls#14176edison1105 merged 1 commit intominorfrom
Conversation
…function to avoid redundant calls.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this comment.
Pull request overview
This PR optimizes dynamic slot rendering performance by caching the results of dynamic slot functions using Vue's computed API, preventing redundant function calls within the same render cycle.
- Adds a caching mechanism using
computedfor dynamic slot functions - Introduces the
resolveDynamicSlothelper to manage cache lifecycle - Reorganizes tests into a dedicated
createForSlotsdescribe block with comprehensive caching behavior tests
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/runtime-vapor/src/componentSlots.ts | Adds _cache property to DynamicSlotFn type, implements resolveDynamicSlot helper function, and updates call sites to use the caching mechanism |
| packages/runtime-vapor/tests/componentSlots.spec.ts | Reorganizes existing test into createForSlots describe block and adds three new tests verifying caching behavior, reactivity updates, and correct rendering |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.