Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#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:
Blocked by: Blocking:

Description (last modified by rwaldron)

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 6 years ago by rwaldron

  • Component changed from unfiled to attributes
  • Keywords manipulation added
  • Owner set to rwaldron
  • Status changed from new to assigned

comment:2 Changed 6 years ago by rwaldron

  • Description modified (diff)

comment:3 Changed 6 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 6 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.

Last edited 6 years ago by rwaldron (previous) (diff)

comment:5 Changed 6 years ago by rwaldron

  • Summary changed from New method: $.fn.classes() to New method: $.fn.classlist()

comment:6 Changed 6 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 6 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.

comment:8 Changed 6 years ago by paul.irish

  • Resolution set to duplicate
  • Status changed from assigned to closed

comment:9 Changed 6 years ago by paul.irish

Duplicate of #5087.

Note: See TracTickets for help on using tickets.