Bug Tracker

Opened 10 years ago

Closed 10 years ago

#13950 closed bug (notabug)

Class attribute instantiated upon .addClass(), but not removed upon .removeClass()

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.0.1
Keywords: Cc:
Blocked by: Blocking:




var x = $( "<div></div>" ).appendTo( "body" ).addClass( "abc" ).removeClass( "abc" );

Leaves x with an attribute class="". This is counter-intuitive since the class of x is absent when addClass is first called, and removeClass is expected to completely revert the action of addClass.

Change History (2)

comment:1 Changed 10 years ago by dmethvin

jQuery always uses the .className property which is an empty string by default. We don't touch the class attribute at all.


What the browser does with the attribute when the property is set back to an empty string is beyond the scope of what those methods accomplish. I'm not sure if it's defined by any spec, but if so it would be DOM0 since it goes back so far.

I've filed a docs ticket: https://github.com/jquery/api.jquery.com/issues/312

comment:2 Changed 10 years ago by dmethvin

Resolution: notabug
Status: newclosed
Note: See TracTickets for help on using tickets.