W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2012

[Bug 17708] New: DOMTokenList: Ability to swap a class

From: <bugzilla@jessica.w3.org>
Date: Fri, 06 Jul 2012 21:29:11 +0000
To: www-dom@w3.org
Message-ID: <bug-17708-4009@http.www.w3.org/Bugs/Public/>

           Summary: DOMTokenList: Ability to swap a class
           Product: WebAppsWG
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DOM
        AssignedTo: annevk@annevk.nl
        ReportedBy: w3c@marcosc.com
         QAContact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, www-dom@w3.org

This is a feature request to add the ability to swap one class for another in

At the W3C advance mobile web dev course, we recently ran an "experiment" where
we asked students to use CSS's "transition:" to show and hide a <p> element
based by clicking on a <h1> element (see https://vimeo.com/43676508 for a video
of what they were asked to build). 

In the results the students submitted, we saw a lot of this:


If developers are going to swap CSS classes around in the method above, then
they might as well have an efficient means to do that. 

Or other similar code. We also saw evidence that developers assume that class
lists retain order:

if(elem.classList === "x y") {

This could lead to confusion when using DOMTokenList toggle(), as toggle
destroys the ordering of CSS class list names of an attribute.  

Given the above, I'll like to request we add swap() method to DOMTokenList().
It would swap one token for another while retaining item order.

Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
Received on Friday, 6 July 2012 21:29:12 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:19 UTC