Skip to main content

Bug Tracker

Side navigation

#4817 closed bug (fixed)

Opened June 25, 2009 09:29AM UTC

Closed November 21, 2010 01:26AM UTC

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:
Description

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

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

Changed November 05, 2010 07:45AM UTC by addyosmani comment:1

keywords: selector, hasClass, class, metacharacterselector, hasClass, class, metacharacter, needsreview

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.

Changed November 21, 2010 01:26AM UTC by jitter comment:2

component: coreattributes
milestone: 1.41.4.2
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.