Opened 12 years ago
Closed 5 years ago
#9628 closed defect (patchwelcome)
dojo.attr not working on IE8 for xml dom node
Reported by: | juzzam | Owned by: | Eugene Lazutkin |
---|---|---|---|
Priority: | high | Milestone: | 1.13 |
Component: | HTML | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description (last modified by )
dojo.attr is not working for me on IE7/8 to retrieve an attribute from an xml dom node (with dojo 1.3).
I've isolated the problem to this code:
dojo.xhrGet({ url: "/public/feed.xml", handleAs: "xml", load: function(xmldoc) { try{ var entry = dojo.query("entry", xmldoc)[0]; var linknode = dojo.query("link", entry)[0]; var url = dojo.attr(linknode, "href"); console.debug(url); } catch(e){console.debug(e);} } }
On Safari and FF the console prints
"http://www.smashingmagazine.com/2009/07/29/misunderstanding-markup-xhtml-2-comic-strip/"
On IE the dojo.attr() line throws this error:
message : Wrong number of arguments or invalid property assignment, number : -2146827838, description : Wrong number of arguments or invalid property assignment, name : TypeError
I have the problem isolated and hosted it here: https://juzzam.org:2121/public/attrBug.html
The xml file is here: https://juzzam.org:2121/public/feed.xml
Attachments (1)
Change History (11)
Changed 12 years ago by
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Owner: | changed from anonymous to Eugene Lazutkin |
---|
comment:3 Changed 12 years ago by
Component: | General → HTML |
---|---|
Description: | modified (diff) |
Milestone: | tbd → future |
Status: | new → assigned |
comment:4 Changed 12 years ago by
The example uses dojo.attr()
to retrieve "href"
. For some reason it has a special treatment in dojo.attr()
. When I was re-writing it I carried over this special treatment mostly because I have no idea why it was a special case in the first place.
If somebody knows the reason, please post it here. Otherwise we have to wait until I do some time-consuming cross-browser testing to see how it behaves.
comment:5 Changed 12 years ago by
Not sure if this is the answer (cos I am too lazy / busy to look in detail at the problem, but found this TRAC while searching for a similar problem with IE and HREF attrs...
see: http://www.glennjones.net/Post/809/getAttributehrefbug.htm
essentially if your href is just a relative href="somelink"..WORKING browsers will correctly return "somelink" from attr('href') whereas IE will (stupidly) return "http://yoursite.com/somelink"
Could this be a) the reason for the "special treatment" ? and perhaps b) thw "wrong number of arguments" error being related to the IE second parameter...?
Microsoft (yet again) dancing to to the beat of its own drum - wrongly, as usual - and screwing it up for everyone. IE needs a developer health warning
comment:6 Changed 12 years ago by
This nasty hack just worked cross-browser for me if you are having the same problem...
function fixlinks(scope){ dojo.query('a.v7_internal',scope).forEach(function(a){ var href=dojo.isIE ? a.getAttribute('href',2):dojo.attr(a,'href'); console.warn("FL original (IE fix)=",href); ...
(Thanks to the helpful Mr Glenn Jones as per the article above!)
comment:7 Changed 9 years ago by
Can we please have an answer in this one? 'Been 3 years now, and no one solve this ticket...
I have a similar issue as you can see bellow, FF/Chrome/Opera/Safari returns the correct data, but I.E. returns an error:
message : Wrong number of arguments or invalid property assignment, number : -2146827838,
This is my simplified code:
dojo.xhrGet({ url: "commerce/xml-items.xml", handleAs: "xml", sync: true, load: function(xml){ console.log(dojo.query("phase", xml).attr("label")); }, error: function (error) { console.error('Error: ', error); } });
Page is working at this URL: http://kadudare.com.br/xmltest , and here is my XML file: http://kadudare.com.br/xmltest/commerce/xml-items.xml
Thanks in advance!
comment:9 Changed 9 years ago by
Shame on dojo support guys, 3 years and not even an answer... Here is it: use .getAttribute instead:
dojo.query("box phase",xml)[0].getAttribute('label')
ps.: Thanks to Michael Santelia!
comment:10 Changed 5 years ago by
Milestone: | future → 1.12 |
---|---|
Resolution: | → patchwelcome |
Status: | assigned → closed |
While it is sad that this didn't get solved years ago, there's no need to say "shame on dojo support guys". It's an open source project, and clearly the team was overloaded with requests.
Given that getAttribute() works pretty universally now, I think that's the answer. If someone wants to patch attr at some point to improve it for its xml handling, a patch would be welcome.
Please assign to Eugene Lazutkin - elazutkin. This is my first bug submission - sorry for not opening it against him in the first place.