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

Javascript vanilla #3

Open
urufudev opened this issue Sep 19, 2022 · 7 comments
Open

Javascript vanilla #3

urufudev opened this issue Sep 19, 2022 · 7 comments

Comments

@urufudev
Copy link

will there be any possibility to do it in javascript without jquery?
i love this package

@westonganger
Copy link
Owner

For my own curiousity and learning I am attempting to do this in #4. This project is a good candidate for the experiment as its a pretty small codebase.

Something I notice right away after putting in a little effort is that the public API of the library changes just to accommodate vanilla JS. So it would be next to impossible to develop jquery/vanilla in tandem.

Other main issue I note is that namespaced events are not built-in to plain JS so requires some hackery.

@westonganger
Copy link
Owner

Tracking the discussion for namespaced jquery events here, HubSpot/youmightnotneedjquery#309

@m0chael
Copy link

m0chael commented Nov 8, 2022

I've created an experimental version of this in Vanilla Js called input-case-enforcer-no-jquery, it's currently attached to the window. I opened a pull request for it. Please let me know if there needs to be any adjustment for the PR to get accepted.

@urufudev
Copy link
Author

I've created an experimental version of this in Vanilla Js called input-case-enforcer-no-jquery, it's currently attached to the window. I opened a pull request for it. Please let me know if there needs to be any adjustment for the PR to get accepted.

Hello. I tried your .js, but when I use it identifying by class name, it only works on the first input, and not on the rest.

<script> document.addEventListener("DOMContentLoaded", function() { window.inputCaseEnforcer.init('.bestupper', 'uppercase'); }); </script>

@m0chael
Copy link

m0chael commented Jan 11, 2023

@urufudev Thanks for trying it out. It currently uses document.querySelector() rather than document.querySelectorAll(), so it would need to specify an ID, or it'll only use the first instance of a class name. I will work on adding support for multiple classes with document.querySelectorAll() in the near future!

@m0chael
Copy link

m0chael commented Jan 11, 2023

@urufudev I've pushed a new version of mine, it should be working now for multiple classes. I tested the main functions which is detailed in the demonstration file index-no-query.html by using window.inputCaseEnforcer.init('.enforced-uppercase', 'uppercase');. Please let me know if that works for you.

@urufudev
Copy link
Author

@urufudev I've pushed a new version of mine, it should be working now for multiple classes. I tested the main functions which is detailed in the demonstration file index-no-query.html by using window.inputCaseEnforcer.init('.enforced-uppercase', 'uppercase');. Please let me know if that works for you.

Thanks, work's fine 😄

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

3 participants