-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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): ensure that binding.instance in custom directive hooks properly exposes properties on closed instances (fix: #5018) #5022
Conversation
…ooks properly exposes properties on closed instances.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Question: This fix does seem to also block the directive from using properties defined on |
I'd say so, yes. This fix was necessary to fix the problem explained in the description, and I believe conceptually, it makes sense that custom directives get access to only he same interface as components would get with a template Looking at the linked context you provided:
Well, However I agree that the workaround mentioned in this issue is not great DX. I think what it comes down to:
A) would be easier to do I think, while B) would be more in line with what I personally think is better conceptually - go for injections rather than global properties to access global/shared state and behavior. This is a discussion unrelated to / bigger than this PR, so feel free to bring it to the surface in its own issue. |
Related issue: #5002 |
@LinusBorg A: Because it's a regression (in a minor nonetheless) and should be fixed |
Hi, |
Same issue still @ primevue, it cannot see '$primevue' and has to be exposed again per-sfc file ... |
For closed instances (those crreated with
<script setup>
or a normal setup function in whichexpose()
has been called), we currently expose a different proxy ("exposeProxy
") for i.e. refs.This proxy provides access to the public instance methods provided by Vue and the explicitly exposed custom properties.
With this PR we now also expose this same
exposeProxy
to custom directives inbinding.instance
so that custom directives can access exposed properties correctly.Edit: I moved this to p4- important as I realized that this is currently working in dev with script-setup, but breaking in prod, which is - bad.
fix: #5018