-
Notifications
You must be signed in to change notification settings - Fork 102
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
Removed jQuery dependency. #8
base: master
Are you sure you want to change the base?
Conversation
Removed jQuery dependency to modern javascript methods.
This is awesome news... I was really excited about this project until I saw a jQuery dependancy. Then, I saw this update. Exactly what issue are you having with adding and removing classes... all modern browsers should support all of the classList functions and there are good shims for older browsers. |
@crispen-smith Basically it's dealing with multiple class add/remove that was an issue. I added two methods using prototype inheritance, but I'm not sure it's the best approach. |
I'm not convinced that adding the functions to the prototype isn't the best option. Have you done much testing on older browsers? At first glance it doesn't look like this will provide support for IE 9-, unless I'm missing something. |
No, this won't work on IE9 and below, as IE9 does not support classlist. |
There seems to be two threads on porting away from JQuery right now and However, I think yours seems to be closer to stable so I'd like to My belief is that there is merit in exploring ClassList shim that the MDN I've used this via require.js with some success for a class based chat On Wed, Nov 6, 2013 at 9:26 AM, hitautodestruct [email protected]:
|
Relying on a shim just for support of an attribute utility might be overkill. BTW, there hasn't been any comment from @kumailht on this fork at all. |
The idealist in me wants a standalone library that has decent test coverage, works on mobile and desktop browsers and can be relied upon. But jQuery brings a lot to the table that is going to be a lot of work to replicate.
I am honestly not sure if removing jQuery is as simple as it seems. The proposed pull requests (this and others) are sacrificing browser support and proper testing. All to replace a dependency which is going to be available on almost all websites. I am torn between the two approaches. I'd like the library to be stand alone but I cannot seem justify the effort required to make it so. |
What bothers me about forcing a JQuery requirement is that it feels, to me, I'm not saying that there shouldn't be a branch that uses JQuery but I do As far as a Shim vs. a library... I am fairly sure the shim is a good On Thu, Nov 7, 2013 at 8:31 AM, Kumail Hunaid [email protected]:
|
isn't this good enough?:
I strongly agree that a jQuery free option should be available here. |
@Ghostavio I think the biggest hurdle in converting this to an independent library, which I am totally for is that doing so requires a bit more than just using classList.
One solution which I think is very workable is including the |
@kumailht yes, that's why I posted a function that checks if classList is available, and then falls back to regex ( |
@kumailht this utility already addresses browsers which don't support +1 on making it jQuery independent. I'll review and contribute on that. |
@kumailht this is a small library I wrote that has the fastest add/remove class implementation I've seen on the web. https://github.com/lifeiscontent/JS-Performance/blob/master/js/html-class-functions.js though, it does use indexOf. |
Migrated the script to native javascript methods and removed the jQuery dependancy.
$(selector)
was replaced with a custom shortcut toquerySelectorAll
..attr()
was replaced withgetAttribute()
..bind()
was replaced withaddEventListener()
.There is a minor issue with dealing with classes.
Maybe there is a better way to implement the add/remove classes other than prototype manipulation?