-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
fix(runtime-core): avoid setting direct ref of useTemplateRef in dev #13449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(runtime-core): avoid setting direct ref of useTemplateRef in dev #13449
Conversation
WalkthroughGuards were added around template-ref assignments via a new Changes
Sequence Diagram(s)sequenceDiagram
participant Component
participant Renderer
participant RefHelper as canSetRef
participant Owner as Owner.refs
Component->>Renderer: render vnode with template ref (rawRef, key k?, for?)
Renderer->>RefHelper: canSetRef(rawRef)
alt canSetRef = true
RefHelper-->>Renderer: true
Renderer->>rawRef: set rawRef.value (element or array)
alt oldRawRef is reactive and has key k
Renderer->>Owner: clear Owner.refs[k]
end
else canSetRef = false
RefHelper-->>Renderer: false
Renderer-->>Owner: update Owner.refs map instead of rawRef.value (if applicable)
end
Renderer->>Component: render complete (refs updated/cleaned)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Assessment against linked issues
Possibly related PRs
Suggested labels
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 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)
⏰ 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)
✨ Finishing Touches
🧪 Generate 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. 🪧 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 (
|
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: |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
Avoid directly setting the ref value in dev mode whenever a ref object from a
useTemplateRef
call is used for rendering, updating only the component owner refs object instead (whichuseTemplateRef
is hooked up to correctly update from).When code like the following:
is compiled in inline mode the output would contain:
which then attempts to update the
myRef
object directly, showing a warning:Set operation on key "value" failed: target is readonly.
; this change should avoid this warning from showing.closes #12852
Summary by CodeRabbit
Tests
Bug Fixes