vue-clipboard2
vue-clipboard2 copied to clipboard
Error in directive clipboard unbind hook
Hello,
When the component is destroyed, I'm getting the following error:
Error in directive clipboard unbind hook: "TypeError: Cannot read property 'destroy' of undefined"
Thanks.
FWIW, I have the same issue. It doesn't seem to matter how the button is removed from the DOM (v-if or a route change), it always results in the same error.
+1, I cannot seem to figure out root cause but I am now gutting this package from my project.
https://github.com/Inndy/vue-clipboard2#sample-2 use this method - and you will don't have issues
My team can confirm this is still an issue when the component is destroyed. You get a slightly better log from firefox: 'Error in directive clipboard unbind hook: "TypeError: el._vClipboard is undefined"'. It would be nice to have the directives working but we can confirm sample2 also works.
+1 same problem here
For what I checked, when the component is loaded with the directives it fires the copy directive.
So instead of firing bind first, it will on some ocasions run unbind first.
When that happen the binding.args have 'copy'.
And it bugs on the last else
else { el._vClipboard.destroy() delete el._vClipboard }
So, to quickly fix this we just need to add
if(!el._vClipboard) return
On the first line of the unbind hook.
PS: This still needs more deep investigation. But at least that would solve this.
best regards
When is the PR from above will be merged? It solves for me too.