-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
base: main
Are you sure you want to change the base?
fix(runtime-core): avoid setting direct ref of useTemplateRef in dev #13449
Conversation
WalkthroughThe changes add conditional logic to the template ref assignment mechanism, introducing a helper that prevents setting Changes
Sequence Diagram(s)sequenceDiagram
participant Component
participant Renderer
participant RefHelper
Component->>Renderer: Render element with useTemplateRef (direct ref, ref_key)
Renderer->>RefHelper: canSetRef(ref)
alt canSetRef = true
RefHelper-->>Renderer: true
Renderer->>Ref: Set ref.value to element
else canSetRef = false
RefHelper-->>Renderer: false
Renderer-->>Ref: Skip setting ref.value
end
Renderer->>Component: Complete render, refs updated
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 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 (4)
✨ Finishing Touches
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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
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