Skip to content
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

Allow el configuration property to be the dom element #106

Closed
lavolpecheprogramma opened this issue Jun 19, 2023 · 4 comments
Closed

Allow el configuration property to be the dom element #106

lavolpecheprogramma opened this issue Jun 19, 2023 · 4 comments

Comments

@lavolpecheprogramma
Copy link

lavolpecheprogramma commented Jun 19, 2023

Hi!
I'm watching the codebase, and it seems that it is not possible to pass a dom element to the el property(selector).
it can be super useful if you want to use coloris with a framework like vue.

Thanks for your work, coloris have a very nice design!

@mdbassit
Copy link
Owner

Thank you for your kind words!

Indeed it is not possible to pass a single dom element as it is fairly inefficient.
I currently have no plans to support that.

@lavolpecheprogramma
Copy link
Author

Hi, thanks for your reply.
Why do you think it is inefficient? You can bind the click and the input listeners directly to the dom node and not on document and then try to match the target :)

@mdbassit
Copy link
Owner

It is inefficient precisely because the event listeners have to be set for each DOM element separately, which for my specific use case is a big no-no.
The other downside is having to reset the event listeners if the DOM tree is rewritten.

@lavolpecheprogramma
Copy link
Author

Thanks for your reply :)
In a webapp with large form with a lot of input and only one coloris instances it can be a bottleneck, because for every input and click your function will be invoked.
i'm not sure that event delegation is better of have two event listeners for each coloris instances but i understand your point of view and if it works better in your use case, it's just fine!
thanks a lot for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants