-
Notifications
You must be signed in to change notification settings - Fork 14.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
[Bug Report] Error in el-switch
when toggling the value causes it to be destroyed
#17602
Comments
I can submit a PR for to fix this. In terms of how, I believe I've seen many places in the code base where the existence of a ref is checked before interacting with it, but these may be cases where the ref is optional. In this scenario I could also avoid the error by checking "_isDestroyed" if that would be preferred. |
I had that bug too, it happens when I rerender my el-form using a key: The quickest solution is add a conditional to see if $refs.input exists, I did a replica of component and applied in my code and it works:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm having the same problem, i wonder if the team has fixed it? |
Same problem please fix 2.15.1 |
Element UI version
2.12.0
OS/Browsers version
Windows 10 / Google Chrome 77.0.3865.90
Vue version
2.6.10
Reproduction Link
https://codepen.io/mattheyan/pen/KKPjNwx
Steps to reproduce
Place an "" inside of a conditionally rendered region (v-if) that is either directly or indirectly driven by the model value the switch is bound to (v-model), so that when the switch is toggled the switch is destroyed. When the change happens, the switch component uses nextTick to delay updating the checkbox value. However, by the time nextTick fires the component has been destroyed and the input no longer exists, resulting in "TypeError: Cannot set property 'checked' of undefined".
What is Expected?
The error should not occur. Since the component is destroyed, it should not try to update the checkbox.
What is actually happening?
The attempt to modify the checkbox value results in an error.
The text was updated successfully, but these errors were encountered: