Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#7378 closed feature (duplicate)

New method: $.fn.classlist()

Reported by: Rick Waldron Owned by: Rick Waldron
Priority: undecided Milestone: 1.5
Component: attributes Version:
Keywords: manipulation Cc:
Blocked by: Blocking:

Description (last modified by Rick Waldron)

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 (9)

comment:1 Changed 12 years ago by Rick Waldron

Component: unfiledattributes
Keywords: manipulation added
Owner: set to Rick Waldron
Status: newassigned

comment:2 Changed 12 years ago by Rick Waldron

Description: modified (diff)

comment:3 Changed 12 years ago by jitter

I guess you mean the HTML 5 classList.

For reference:

HTML5: classList and HTML5: DOMTokenList

Mozilla element.classList

Webkit svn

comment:4 Changed 12 years ago by Rick Waldron

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.

Last edited 12 years ago by Rick Waldron (previous) (diff)

comment:5 Changed 12 years ago by Rick Waldron

Summary: New method: $.fn.classes()New method: $.fn.classlist()

comment:6 Changed 12 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 12 years ago by Rick Waldron

I should've updated this ticket some time ago. Yes - thats the direction I've taken - no new api, but perf boosts where possible.

comment:8 Changed 12 years ago by paul.irish

Resolution: duplicate
Status: assignedclosed

comment:9 Changed 12 years ago by paul.irish

Duplicate of #5087.

Note: See TracTickets for help on using tickets.