Bug Tracker

Ticket #7378 (closed feature: duplicate)

Opened 4 years ago

Last modified 3 years ago

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

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

comment:2 Changed 4 years ago by rwaldron

  • Description modified (diff)

comment:3 Changed 4 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 4 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 4 years ago by rwaldron (previous) (diff)

comment:5 Changed 4 years ago by rwaldron

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

comment:6 Changed 4 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 4 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 4 years ago by paul.irish

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

comment:9 Changed 4 years ago by paul.irish

Duplicate of #5087.

Note: See TracTickets for help on using tickets.