Ticket #3091 (closed bug: invalid)
$('.myClass' + integer) does not work in IE
| Reported by: | Ezel_Derbier | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.3 |
| Component: | selector | Version: | 1.2.6 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I need to associate some database ID's to table rows. In order to do that, I use some class names. Here is an example :
<tr id="row55" class="procedure_row level2 section5 depends4">
When I want to target some rows by using one of their class names, I use a code like this :
var id = 4;
var rows = $('.depends' + id);// is supposed to look for '.depends4'
This piece of code gives me three table rows in Firefox 3. This is correct. Nevertheless, I got no line in IE 8 beta 1 (used in 'Emulate IE 7' mode).
Attachments
Change History
comment:1 Changed 5 years ago by flesler
- need changed from Review to Test Case
- Component changed from core to selector
comment:2 Changed 5 years ago by Ezel_Derbier
I think I found where the problem is. This is not a problem of classes ended by numeric values. Instead, it is a kind of 'multiple lines in attributes' problem. I suppose this can affect any HTML attribute.
The content of my class attributes is written on more than one line, like in the exemple below. This does not cause any problem with Firefox but IE does not like it. Same problem in Safari 3.1 on Windows XP.
<!-- Do not work in IE --> <tr class="month someClass otherClass goodbye foo3 bar12 hello78">
<!-- IE is happy with single line --> <tr class="month someClass otherClass goodbye foo3 bar12 hello78">
Everything works in my test case when class attributes are written on a single line.
P.S. : sorry for my 'basic English'
comment:3 Changed 5 years ago by flesler
- Status changed from new to closed
- Resolution set to invalid
I think you can't put new lines inside attributes, it might be invalid html. While some browsers will bear, it's still wrong.
I really don't think this needs a patch, just make them all new line.
Cheers
comment:4 Changed 5 years ago by Ezel_Derbier
I agree with you. I've just checked the HTML 4.01 Specification (section 3.2.2, about attributes), it says the following :
The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58).
User agents should not accept multilines values for HTML and XHTML attributes. Firefox seems to be too much tolerant, even when it renders pages in Standards mode.
Thank you
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Can you please provide a test case ? that is, a small html file with the minimum html/css/js necessary to reproduce the problem. Thanks