Bug Tracker

Ticket #1591 (assigned bug)

Opened 1 year ago

Last modified 4 months ago

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

Reported by: jdsharp Assigned to: flesler (accepted)
Type: bug Priority: major
Milestone: 1.2.4 Component: core
Version: 1.2 Keywords:
Cc: Needs: Review

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 (0.7 kB) - added by jdsharp 1 year ago.
Test case
jquery-1.2.js (77.8 kB) - added by jdsharp 1 year ago.
Changes at line 860
ie-table-attr-namespace.patch (2.1 kB) - added by jdsharp 4 months ago.
Patch against 5711

Change History

Changed 1 year ago by jdsharp

Test case

Changed 1 year ago by jdsharp

Changes at line 860

follow-up: ↓ 2   Changed 1 year 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 );

in reply to: ↑ 1   Changed 1 year ago by digitalspaghetti

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

  Changed 9 months ago by jdsharp

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

  Changed 5 months 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.

  Changed 4 months ago by jdsharp

  • status changed from closed to reopened
  • resolution deleted

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

Changed 4 months ago by jdsharp

Patch against 5711

  Changed 4 months ago by flesler

  • owner set to flesler
  • status changed from reopened to new

  Changed 4 months ago by flesler

  • status changed from new to assigned
Note: See TracTickets for help on using tickets.