Opened 10 years ago

Closed 10 years ago

#9560 closed enhancement (fixed)

[patch][cla] dojo.removeClass w/o class name should remove all classes

Reported by: Les Owned by: Eugene Lazutkin
Priority: low Milestone: 1.4
Component: Core Version: 1.3.0
Keywords: Cc:
Blocked By: Blocking:

Description

It should be easy to remove all class names from an element, e.g.:

This code removes the 'someClass' class.

dojo.removeClass("someNode", "someClass");

This code should remove all classes from someNode.

dojo.removeClass("someNode");

I think this would be an improvement for chaining.

Attachments (1)

removeClass.patch (1.1 KB) - added by dante 10 years ago.
how i'd do it.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 10 years ago by Les

Example (remove all classes, add class 'myClass'):

dojo.query('a').removeClass().addClass('myClass');

Changed 10 years ago by dante

Attachment: removeClass.patch added

how i'd do it.

comment:2 Changed 10 years ago by dante

Summary: dojo.removeClass w/o class name should remove all classes[patch][cla] dojo.removeClass w/o class name should remove all classes

i can't decide if I think this confuses me or is good functionality. It does fill a gap transparently with removeClass, but really

dojo.clearClass = function(node){ dojo.byId(node).className = ""; }

is "less confusing" and can be put in NodeList? too. Hiding in removeClass is less bytes, but adds extra check to code path.

patch is against [18844] in trunk.

comment:3 Changed 10 years ago by Eugene Lazutkin

IMHO, it is confusing, and doesn't save much code.

It makes more sense in the context of NodeList. Probably should be an extension, rather than part of the base.

comment:4 Changed 10 years ago by Les

removeClass() is available in jQuery. I thought it should be added to dojo, since the NodeList? methods are intended to match the API naming and behavior as the similarly named methods in jQuery.

comment:5 Changed 10 years ago by James Burke

Milestone: tbd1.4

Seems fine to me, and as Les mentions we get better compatibility with jquery methods.

comment:6 Changed 10 years ago by Eugene Lazutkin

Component: GeneralCore
Owner: changed from anonymous to Eugene Lazutkin
Status: newassigned

Should be combined with #9577.

comment:7 Changed 10 years ago by Eugene Lazutkin

(In [19075]) Adding array support to addClass/removeClass, adding support to remove all classes, adding unit tests and inline docs, thx Les!, !strict. refs #9577, refs #9560.

comment:8 Changed 10 years ago by Eugene Lazutkin

(In [19076]) removing trailing spaces, !strict, refs #9560, refs #9577.

comment:9 Changed 10 years ago by Eugene Lazutkin

Priority: normallow

Now I want to update the docs on Dojo Campus but I don't know what is the correct way to do it: this functionality is unreleased yet. Do we mark it somehow? Do we update some special area? How do we handle docs for different versions?

comment:10 Changed 10 years ago by bill

Previously we were (in theory) marking new stuff with "New in 1.4" but I think at this point you can just document it.

comment:11 Changed 10 years ago by Eugene Lazutkin

Resolution: fixed
Status: assignedclosed

All information is added to the release nodes, and the documentation is updated.

Note: See TracTickets for help on using tickets.