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

typeahead is not namespaced #17

Open
TomHAnderson opened this issue Dec 28, 2021 · 2 comments
Open

typeahead is not namespaced #17

TomHAnderson opened this issue Dec 28, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@TomHAnderson
Copy link
Contributor

This library is very useful for widget development where HTML is being injected into an unknown website, but the lack of namespacing of the core function threatens collisions. This library defines one global function called typeahead. I'm very concerned that should I use this library it will collide with my client's website. I'm injecting HTML directly into their pages as widgets.

So, although I do not have an example of such a collision I'm very wary about it. This is my suggested solution:

export default function digitalfortress$typeahead<T extends Dictionary>(config: typeaheadConfig<T>): typeaheadResult {

I understand such a central change to this library would necessitate a major version number and would cause a bit of documentation rewriting, but other than that I don't foresee much of a problem.

@TomHAnderson
Copy link
Contributor Author

Other libraries have addressed namespacing differently but this library defines a global function so this approach may not be as appropriate

https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/

<script src="https://cdn.jsdelivr.net/npm/@algolia/autocomplete-js"></script>
<script>
  const { autocomplete } = window['@algolia/autocomplete-js'];
</script>

@niketpathak niketpathak added the enhancement New feature or request label Dec 28, 2021
@niketpathak
Copy link
Collaborator

Hello,
Thank you for your suggestion. Although the chance for collisions remains pretty slim (given that these days, its pretty common to bundle an app into a single javascript file thereby not exposing typeahead to the window object at all). Nonetheless, for people who intend to directly use the library (for example via CDN) could face collisions, so this will be taken into consideration for the next major release. Thanks again.

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

No branches or pull requests

2 participants