Bug Tracker

Opened 14 years ago

Closed 12 years ago

#4817 closed bug (fixed)

hasClass expands selector metacharacters

Reported by: sixtease Owned by:
Priority: low Milestone: 1.4.2
Component: attributes Version: 1.3.2
Keywords: selector, hasClass, class, metacharacter, needsreview Cc:
Blocked by: Blocking:


hasClass method doesn't recognize classes with dots and other metacharacters. They must be escaped.

<div id="dotclass" class="has.dot"></div>
if ( $('#dotclass').hasClass('has.dot') ) alert('works');
else alert('fails');
if ( $('#dotclass').hasClass('has\\.dot') ) alert('works with \\\\');

Attachments (2)

jquery-hasClass.diff (560 bytes) - added by sixtease 14 years ago.
hasClass-test.html (757 bytes) - added by sixtease 14 years ago.

Download all attachments as: .zip

Change History (4)

Changed 14 years ago by sixtease

Attachment: jquery-hasClass.diff added


Changed 14 years ago by sixtease

Attachment: hasClass-test.html added


comment:1 Changed 12 years ago by addyosmani

Keywords: needsreview added

Your test case works fine using both the standard '.' form and a single forward-slash. Given that a well-named class shouldn't contain multiple meta-characters (eg.

\) in the first place, I want to flag this as an edge-case that probably will not be experienced by a large number of users. Leaving it open for now.

comment:2 Changed 12 years ago by jitter

Component: coreattributes
Priority: minorlow
Resolution: fixed
Status: newclosed

test case was fixed with 1.4.2.

If the bug still exists for you, feel free to reopen with a test case.

Note: See TracTickets for help on using tickets.