Ticket #7378 (closed feature: duplicate)
New method: $.fn.classlist()
| Reported by: | rwaldron | Owned by: | rwaldron |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.5 |
| Component: | attributes | Version: | |
| Keywords: | manipulation | Cc: | |
| Blocking: | Blocked by: |
Description (last modified by rwaldron) (diff)
Essentially, a jQuery method that wraps the brains of classList where available and provides a fallback where it isn't available. I'll provide more details via jsfiddle's when I get a chance.
Change History
comment:1 Changed 3 years ago by rwaldron
- Keywords manipulation added
- Owner set to rwaldron
- Status changed from new to assigned
- Component changed from unfiled to attributes
comment:3 Changed 3 years ago by jitter
comment:4 Changed 3 years ago by rwaldron
yes, thats what I'm thinking. Thanks for posting the resource info
Additionally, I put together these minimal requirements:
Should: feature detect (adds a test for classList to jQuery.support), normalize functionality for both native and non-native, support classList functionality
I spent the morning writing a draft of this and will have a repo available soon. Its very tight so far and offers: item(), add(), remove(), contains() and toggle() - using jQuery's own methods
Additionally, I have 59 unit tests written. Will start writing an api doc asap so it can be use tested.
comment:5 Changed 3 years ago by rwaldron
- Summary changed from New method: $.fn.classes() to New method: $.fn.classlist()
comment:6 Changed 2 years ago by paul.irish
Since addClass/removeClass etc is the abstraction jQuery provides for classes, why wouldn't those methods just use elem.classList if available for the added perf?
Changing the API for class manipulation as a sort of polyfill seems like its not really jquery's style.
comment:7 Changed 2 years ago by rwaldron
I should've updated this ticket some time ago. Yes - thats the direction I've taken - no new api, but perf boosts where possible.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
