Opened 16 years ago
Closed 13 years ago
#220 closed bug (fixed)
Nathan
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | |
Component: | ajax | Version: | |
Keywords: | Nathan | Cc: | Nathan |
Blocked by: | Blocking: |
Description (last modified by )
I am using jQuery to work with XML documents that are parsed in the browser. However using the .attr(String) method fails with an error in IE.
I have tracked down the problem, which appears to be different implementations of 'getAttribute' between the HTML DOM and XMLDOM in IE.
I have attached a patch with a test case and my fix. Unfortunately the fix consists of catching the error and calling the other version of the function, which seems a bit clunky.
Attachments (4)
Change History (9)
Changed 16 years ago by
Attachment: | jquery-220.patch added |
---|
Changed 16 years ago by
Attachment: | jquery-220.2.patch added |
---|
Changed 16 years ago by
Attachment: | jquery-220.3.patch added |
---|
Changed 16 years ago by
Attachment: | jquery-220-patch.txt added |
---|
comment:1 Changed 16 years ago by
Index: src/jquery/jquery.js =================================================================== --- src/jquery/jquery.js (revision 361) +++ src/jquery/jquery.js (working copy) @@ -392,6 +392,14 @@ * @test ok( $('#name').attr('name') == "name", 'Check for name attribute' ); * @test ok( $('#text1').attr('name') == "action", 'Check for name attribute' ); * @test ok( $('#form').attr('action') == "formaction", 'Check for action attribute' ); + * @test var xmltext = '<test><child myattr="hello"/></test>'; + * var xmldoc; + * try { + * xmldoc = new DOMParser().parseFromString(xmltext, 'text/xml'); + * } catch(ex) { + * xmldoc = new ActiveXObject('Microsoft.XMLDOM'); xmldoc.loadXML(xmltext); + * } + * ok( $('child', xmldoc).attr('myattr') == "hello", 'Check for read attribute from XML doc' ); * * @name attr * @type Object @@ -1824,9 +1832,13 @@ if ( fix[name] ) { if ( value != undefined ) elem[fix[name]] = value; return elem[fix[name]]; - } else if ( elem.getAttribute != undefined ) { + } else if ( typeof elem.getAttribute != "undefined" ) { if ( value != undefined ) elem.setAttribute( name, value ); - return elem.getAttribute( name, 2 ); + try { + return elem.getAttribute( name, 2 ); + } catch(ex) { + return elem.getAttribute(name); + } } else { name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();}); if ( value != undefined ) elem[name] = value;
comment:3 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
This has been fixed in the latest SVN.
comment:4 Changed 16 years ago by
Cc: | Nathan added; "" removed |
---|---|
Component: | → 1 |
Keywords: | Nathan added; attr xml removed |
Milestone: | → 1 |
Priority: | → 1 |
Summary: | in IE .attr(String) fails with an error on an XMLDOM document → Nathan |
Type: | → 1 |
Version: | → 1 |
comment:6 Changed 13 years ago by
Component: | → ajax |
---|---|
Description: | modified (diff) |
need: | → Review |
Priority: | → blocker |
Resolution: | → fixed |
Status: | new → closed |
Type: | → bug |
Reopened by spammer.
Note: See
TracTickets for help on using
tickets.
patch for the problem