Ticket #9795 (closed bug: fixed)
IE7,8 Has Attribute Selector for Colspan in TD and TH Tags
| Reported by: | adamterlson | Owned by: | mikesherov |
|---|---|---|---|
| Priority: | low | Milestone: | 1.8 |
| Component: | attributes | Version: | 1.6.2 |
| Keywords: | ie7 ie8 | Cc: | |
| Blocking: | Blocked by: |
Description
In all versions of jQuery, including the latest (1.6.2), in both IE7 and IE8, a has-attribute selector will return false positives for all TH tags when testing for the colspan attribute.
Tested on Windows 7.
I submit this hoping something can be done about this, despite its roots likely being in the [flawed] browsers themselves.
Example HTML:
<table id="one"><tr><th>fred</th></tr></table> <table id="two"><tr><td>fred</td></tr></table>
Example JS:
alert($('#one').find('th[colspan!=""]').length); //Returns 1
alert($('#one').find('th[colspan]').length); //Returns 1
alert($('#two').find('td[colspan!=""]').length); //Returns 1
alert($('#two').find('td[colspan]').length); //Returns 1
$('#one').find('th').each(function() {
alert('colspan:' + $(this).attr('colspan')); //Returns 1 in IE7,8 and "undefined" otherwise
});
Clearly, given this code sample, this attribute should return 0 in IE7 and 8, as it does with IE9, FireFox, and Chrome.
In the last loop, you will see that I output the attribute of the colspan for the TH in the table. In IE7 and 8, a "1" is returned, meaning a colspan of "1". In IE9, and all non-IE browsers, "undefined" is the result as expected.
Thank you, and my apologies if this has been reported (I, however, could not find a duplicate).
Change History
comment:1 Changed 2 years ago by timmywil
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to attributes
comment:3 Changed 10 months ago by mikesherov
- Owner set to mikesherov
- Status changed from open to assigned
- Milestone changed from 1.next to 1.8
This was fixed in the Sizzle rewrite in 1.8. timmywil, do you have a test case covering this situation? If so, let me know so we can close this, otherwise, I can write a test for this.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Confirmed. Issue is in both attributes and selector modules.
Without alerts: http://jsfiddle.net/timmywil/GHXBH/7/