-
Notifications
You must be signed in to change notification settings - Fork 86
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
Support for inline expressions #34
Comments
Hi, @Danktuary indeed this could simplify things, sorry for the delay in answering this. I think this can be solved using the binding expression. |
Sure, I don't mind giving it a shot! No promises though because I don't have much experience with Vue directive dev. 😅 But I'll give it a go in the next couple days. |
@ndelvalle , is there any development in this direction? |
@drank not at the moment 😔. Any help would be appriciated 👍 |
@ndelvalle It seems we cannot make it possible to support inline expressions as we want. Check this issue Evan You answered: vuejs/vue#6753 Arrow functions might get things done, but it does not work properly based on current release(2.1.1) because v-click-outside/lib/v-click-outside.js Line 58 in cb62ea3
As a result, it will repeatly add the same anonymous listener everytime we click outside the element. We need to do some improvements to fully support these usages below. (I'm still trying:dizzy_face:...)
(Other common cases)
|
@monkeyWzr I see. I thought this was going to be possible without the arrow function, but apparently not. About the arrow function usage: const func = (arg) => console.log(arg)
// Add event listener
document.addEventListener('keyup', func)
// Remove event listener
document.removeEventListener('keyup', func) |
@ndelvalle Thanks a lot! |
@ndelvalle Sorry I was focusing on the wrong point. The reason the The current code for binding v-click-outside/lib/v-click-outside.js Line 74 in c59e1d3
somehow makes setTimeout(() => document.addEventListener(event, handler), 0)
Please check the PR #69 (including test cases updates). Thank you very much! |
Support for inline expressions would be neat. Instead of doing all this:
It could be simplified to this:
Of course, that probably isn't the only use-case, but just the first one that comes to mind. 😄
The text was updated successfully, but these errors were encountered: