Opened 12 years ago

Closed 12 years ago

#3227 closed defect (fixed)

add "toggleClass" method to dojo base

Reported by: owen Owned by: anonymous
Priority: high Milestone:
Component: General Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description

(Cleared with Alex)

Add a method that takes a condition to turn a class on/off. So rather than this:

dojo[condition?"addClass":"removeClass"](node,"someClass")

you can now do this:

dojo.toggleClass(node, someClass, condition)

Note that if condition is undefined, this will turn the class of if it's on, or on if it's off. So you may need to do:

dojo.toggleClass(node, someClass, !!condition)

or some such.

Change History (5)

comment:1 Changed 12 years ago by owen

Resolution: fixed
Status: newclosed

(In [8850]) fixes #3227 Add dojo.toggleClass method. See bug for details.

comment:2 Changed 12 years ago by Eugene Lazutkin

(In [8851]) Reverting the previous change. Refs #3227.

comment:3 Changed 12 years ago by bill

Resolution: fixed
Status: closedreopened

I'm not sure what you guys are up to; Owen checked in a giant changeset and Eugene reverted it, so this bug should remain open (or at least have a status other than "fixed").

Speaking of which, this is a duplicate of #2455, which I just closed as "wontfix" but actually I don't care if this function is there or not.

You should use braces on your if statements though, as per coding standards.

comment:4 Changed 12 years ago by Eugene Lazutkin

Owen asked me to revert it temporarily, and I helped him to do it. I'll update the code to be conformant.

comment:5 Changed 12 years ago by Eugene Lazutkin

Resolution: fixed
Status: reopenedclosed

(In [8863]) Minor stylistic changes. Fixes #3227.

Note: See TracTickets for help on using tickets.