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

Dynamic Awesomplete? #17174

Open
LeaVerou opened this issue Jan 30, 2019 · 3 comments
Open

Dynamic Awesomplete? #17174

LeaVerou opened this issue Jan 30, 2019 · 3 comments

Comments

@LeaVerou
Copy link
Owner

@karger just brought this up. He was using an Awesomplete input as an editor template for Mavo and it wasn't working, since these awesomplete elements were created after startup.

It is possible (and fairly easy) to use a MutationObserver to observe for new elements that match input.awesomplete and have not been initialized yet and initialize them. However, that means we'd need to have a mutation observer on the entire <body> element that listens for every single node being added (subtree: true), which worries me performance-wise.

Another way to do it would be to have an event listener on <body> for the input event, which would be used for both Awesomplete functionality as well as to check if the target matches input.awesomplete and has not been initialized yet. This is likely more performant (since it's throttled by biology), but trickier to implement and still listens to events on the entire document. Also, keeping inputs uninitialized until first used may have unintended consequences for some use cases.

@davidkna
Copy link
Contributor

An alternative might be to use a custom element Web Components but the browser support isn't as good.

@karger
Copy link

karger commented Jan 30, 2019 via email

@LeaVerou
Copy link
Owner Author

@karger If you want to argue that case, argue it to the WHATWG guys who can actually do something about it:

whatwg/dom#77
whatwg/dom#398

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

No branches or pull requests

3 participants