Bug Tracker

Opened 10 years ago

Closed 10 years ago

#4761 closed bug (duplicate)

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 (799 bytes) - added by pbcomm 10 years ago.
Patch, replacing line breaks with spaces

Download all attachments as: .zip

Change History (4)

comment:1 Changed 10 years ago by pbcomm

This happens on IE only.

Changed 10 years ago by pbcomm

Attachment: jquery-1.3.2.js.diff added

Patch, replacing line breaks with spaces

comment:2 Changed 10 years ago by docwhat

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

comment:3 Changed 10 years ago by dmethvin

Resolution: duplicate
Status: newclosed

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

Note: See TracTickets for help on using tickets.