Bug Tracker

Modify

Ticket #9795 (closed bug: fixed)

Opened 2 years ago

Last modified 9 months ago

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
});

 http://jsfiddle.net/GHXBH/6/

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

Confirmed. Issue is in both attributes and selector modules.

Without alerts:  http://jsfiddle.net/timmywil/GHXBH/7/

comment:2 Changed 16 months ago by dmethvin

  • Keywords ie7 ie8 added

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.

comment:4 Changed 10 months ago by timmywil

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.

comment:5 Changed 9 months ago by mikesherov

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.