Remove DOM element
nadinengland opened this issue · 3 comments
Love the package, used it for ages, thanks a million for making it!
Is it possible to include the component without it's DOM element? Currently I remove the DOM element with CSS but it would be nice if this wasn't there in the first place as I can't see what value or features it gives being included.
vue-global-events/src/index.js
Line 39 in 405b25a
The render function simply calls createElement
, but could it be replaced with h => null,
? Which I believe would make Vue render the component out as a comment: <!-- -->
I can't see anywhere in the codebase that actually uses $el
so I don't believe this would have a knock on effect to the package itself, but I could be missing something that might make it a breaking change for user of the package. Would be good to get other people thoughts.
We do rely on it being mounted/removed though as this allows us to turn the listeners on/off with a v-if
. But this might still work the way you suggested – will have to investigate! Thanks for the suggestion! I’m glad you like the library 😃
It appears that Vue still respects these lifetime hooks even when you don't have a DOM element. I've made a quick codepen to demo that at least: https://codesandbox.io/s/wonderful-neumann-cnm2l
This is already implemented in v2