Skip to main content

Bug Tracker

Side navigation

#9795 closed bug (fixed)

Opened July 11, 2011 01:19PM UTC

Closed September 30, 2012 01:46AM UTC

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:
Blocked by: Blocking:

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).

Attachments (0)
Change History (5)

Changed July 11, 2011 01:45PM UTC by timmywil comment:1

component: unfiledattributes
priority: undecidedlow
status: newopen

Confirmed. Issue is in both attributes and selector modules.

Without alerts:

Changed March 03, 2012 08:55PM UTC by dmethvin comment:2

keywords: → ie7 ie8

Changed September 04, 2012 02:16AM UTC by mikesherov comment:3

milestone: 1.next1.8
owner: → mikesherov
status: openassigned

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.

Changed September 04, 2012 02:45PM UTC by timmywil comment:4

We don't have tests for colspan specifically, but we do now have tests in Sizzle covering empty string values and in jQuery's selector tests covering attribute presence. I'm always happy to add more tests though.

Changed September 30, 2012 01:46AM UTC by mikesherov comment:5

resolution: → fixed
status: assignedclosed

If you already have equivalent tests here timmywil, I'm just closing this as fixed then.