-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Template refs to non-Ref class instances error in production builds, but not during development #12029
Comments
duplicate of #11373 |
@edison1105 Are you sure this is a duplicate? I've looked through #11373, and also through #4866 (linked there), and both of these issues reference situations that use dynamically assigned template refs, i.e. code that uses This is NOT what is going on here in my issue. I have a hardcoded reference to This issue is similar to the other two in the sense that it concerns template refs and dev/prod build differences, however the bug itself feels different. Maybe I'm wrong here and they are related; could you elaborate how this issue and the other two are caused by the same defect? |
You can switch between DEV and PROD to inspect the compiled code. At runtime
Developers should follow the documentation
|
Looked at #12031 and I think the correct change should be detecting such usage during development (when setting the template ref, if the key exists on |
Vue version
3.5.8
Link to minimal reproduction
https://play.vuejs.org/#__PROD__eNp9UsFq4zAQ/ZVZXZJCcA7dwBLSQroEtntolm5gL4JFlceJWlkSGtlOCPn3HdlpmsNSX6x574385o2PYhlC0TYo5mJBOpqQgDA14V666RQ2O0OgfYlQeiRwPu2M24JxUGILL42xJU34naBSxlImQvTlmZlLp60igiUcT3z2jhIEuAOHHSzHN9L1H/mzUwmUJQ8Yo4+5jdGsK71uanSp0BFVwpXFXI1HYcS9Z01nXOm7vnw4QJfvegStHI+BbE2R0craAyh3GMynLOGxWGLYkHIawVegYPCqXAlP6w3Xz1gV1xZzBG6UBpcfJmeX0xHUHGbAo56BiNX4BvLDwPqlNb4htsI+CDof3+iLdIvpEDsHzkXCOlgelSuARcg33EkRpLj/gdb6xTQvZjG9komJSMTRVmZbvJJ3vMhjbpZC+zoYi3EdkuHopZhDz2SOI/Hdzx5LscHJO653qN/+g7/SPmNS/IpIGFuU4sIlFbeYBnr1+wn3fL6QtS8by+pPyGckb5vscZA9NK5k21e63u1jHXxMvMENrfYJHb0PlY1m5anXS8F/8/dPRv+we1t87fukO3GKf1uM+U4O8LaYFd/E6R/KqQUI
Steps to reproduce
Run the reproduction, it explains the issue with comments:
The code works fine in dev mode, but breaks in prod builds.
In this case, the component renders successfully in both cases (albeit with the error in prod); however, in actual projects of mine this has typically nuked the entire page.
What is expected?
Template refs pointing to something other than an actual vue Ref is not intentional code. This kind of code has happened in my projects a few times due to oversight; basically due to coding errors. The problem here is that the error is silent during development - the ref might be wrong, but it does not nuke the component and just fails silently. So you never fix it.
Consistency is expected here. I argue that this should fail also in dev, albeit with a nicer error message. It should point out that you have an element that's template ref'd to an object that doesn't make sense.
Alternatively, it should ignore the issue silently in production builds, just like it does in dev now.
What is actually happening?
In dev, the issue is ignored silently and with no repercussions, but in prod it fails loud.
System Info
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: