Skip to main content

Bug Tracker

Side navigation

#4761 closed bug (duplicate)

Opened June 14, 2009 07:10AM UTC

Closed November 14, 2009 03:37PM UTC

hasClass() can't parse classes with newlines.

Reported by: docwhat Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

hasClass() doesn't properly parse classes with newlines.

Here's a simple page to reproduce it.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html><body>

<div id="div1" class="one
two">buggy?</div>

<script
    type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function () {
  var el = $('div#div1');
  if (el.hasClass('one')) {
    el.text('No bug! Yay!');
  } else {
    el.text('The bug is present. Boo.');
  }
});  
</script>

</body></html>
Attachments (1)
  • jquery-1.3.2.js.diff (0.8 KB) - added by pbcomm June 14, 2009 06:22PM UTC.

    Patch, replacing line breaks with spaces

Change History (3)

Changed June 14, 2009 05:40PM UTC by pbcomm comment:1

This happens on IE only.

Changed June 18, 2009 07:19PM UTC by docwhat comment:2

@pbcomm: It breaks FF 3.5betaWhatever on Mac OS X as well.

Changed November 14, 2009 03:37PM UTC by dmethvin comment:3

resolution: → duplicate
status: newclosed

Dup of #5505, which has a better patch. (This one requires \\r\\n in sequence.)