Bug Tracker

Modify

Ticket #1591 (closed bug: fixed)

Opened 7 years ago

Last modified 2 years ago

IE "Invalid Argument" $('table').attr('non-existent')

Reported by: jdsharp Owned by: timmywil
Priority: high Milestone: 1.6
Component: attributes Version: 1.2
Keywords: Cc:
Blocking: Blocked by:

Description

IE 6 throws an "Invalid Argument" error when attempting to get an attribute from a table element. Functions as desired with a div (returns undefined). Fix attached. (Is broken in 1.1.3.1, 1.1.4, 1.2)

Attachments

attr.html Download (701 bytes) - added by jdsharp 7 years ago.
Test case
jquery-1.2.js Download (77.8 KB) - added by jdsharp 7 years ago.
Changes at line 860
ie-table-attr-namespace.patch Download (2.1 KB) - added by jdsharp 6 years ago.
Patch against 5711

Change History

Changed 7 years ago by jdsharp

Test case

Changed 7 years ago by jdsharp

Changes at line 860

comment:1 follow-up: ↓ 2 Changed 7 years ago by jdsharp

Some more research reveled that this only occurs when the attribute in question contains a ':'. Updated patch as follows:

Fixes a getAttribute 'Invalid Exception' error when getting an attribute with a ':' in it on a table element when the attribute does not exist  http://www.andrewdupont.net/2007/01/10/code-hasattribute-for-ie/ if ( jQuery.browser.msie ) {

if ( /href|src/.test(name) && !jQuery.isXMLDoc(elem) )

return elem.getAttribute( name, 2 );

if ( name.indexOf(':') > -1 )

return ( elem.attributes[name] != undefined ? elem.getAttribute(name) : undefined );

} return elem.getAttribute( name );

comment:2 in reply to: ↑ 1 Changed 7 years ago by digitalspagh

Replying to jdsharp:

Some more research reveled that this only occurs when the attribute in question contains a ':'. Updated patch as follows:

Fixes a getAttribute 'Invalid Exception' error when getting an attribute with a ':' in it on a table element when the attribute does not exist  http://www.andrewdupont.net/2007/01/10/code-hasattribute-for-ie/ if ( jQuery.browser.msie ) {

if ( /href|src/.test(name) && !jQuery.isXMLDoc(elem) )

return elem.getAttribute( name, 2 );

if ( name.indexOf(':') > -1 )

return ( elem.attributes[name] != undefined ? elem.getAttribute(name) : undefined );

} return elem.getAttribute( name );

Tried the above patch, does not fix the error in IE6, however this did fix a problem I was having in Safari on Windows XP. I was trying to use hover() and hoverIntent() on an unordered list, and neither worked - however this fix solved the problem

comment:3 Changed 6 years ago by jdsharp

This bug is still present in 1.2.2 and the same patch still applies.

comment:4 Changed 6 years ago by flesler

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from 1.2.1 to 1.2.4

Tested this with the trunk version, and it works fine. This was probably fixed with the recent massive modifications to .attr().

I tested on IE6.

comment:5 Changed 6 years ago by jdsharp

  • Status changed from closed to reopened
  • Resolution fixed deleted

This issue still existed in 1.2.6, I've created a patch against trunk

Changed 6 years ago by jdsharp

Patch against 5711

comment:6 Changed 6 years ago by flesler

  • Owner set to flesler
  • Status changed from reopened to new

comment:7 Changed 6 years ago by flesler

  • Status changed from new to assigned

comment:8 Changed 5 years ago by moxiecode

Any progress on this one? It's been 8 months and I'm still able to reproduce this in jQuery 1.3.1.

comment:9 Changed 5 years ago by dmethvin

See the discussion in dup #3278

comment:10 Changed 3 years ago by danheberden

  • Milestone changed from 1.2.4 to 1.next

Still an issue - IE9 can't get at all on a table element :/

however, document.getElementById( 'table1' ).getAttribute( 'ric:attrib' ) works just fine

 http://jsfiddle.net/danheberden/YxRUP/

Last edited 3 years ago by danheberden (previous) (diff)

comment:11 Changed 3 years ago by timmywil

What about  http://jsfiddle.net/timmywil/YxRUP/2/? I don't have IE9 to test.

comment:12 Changed 3 years ago by timmywil

Actually, still a problem in IE6 in that test.

comment:13 Changed 3 years ago by john

  • Owner flesler deleted
  • Status changed from assigned to open

Updated version of the test case using jQuery git:  http://jsfiddle.net/YxRUP/3/

comment:14 Changed 3 years ago by timmywil

  • Owner set to timmywil
  • Priority changed from major to high
  • Status changed from open to assigned

Dan's, John's, and my test cases all pass in IE9 so I don't think this is a problem in IE9, but it is a problem for IE6/7. Any attribute with a colon on a table element throws an "Invalid Argument" exception. I've created another  test case as well. Working on a possible fix.

comment:15 Changed 3 years ago by timmywil

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

Test for a colon in attribute names for IE6/7. Fixes #1591.

Changeset: 24a8ffb3eae56345231931184891f25f6ce017cf

comment:16 Changed 3 years ago by timmywil

  • Milestone changed from 1.next to 1.6

comment:17 Changed 3 years ago by john

  • Component changed from core to attributes

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.