Opened 12 years ago

Closed 6 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 Eugene Lazutkin)

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:

  url: "/public/feed.xml",
  handleAs: "xml",
  load: function(xmldoc) {
      var entry = dojo.query("entry", xmldoc)[0];
      var linknode = dojo.query("link", entry)[0];
      var url = dojo.attr(linknode, "href");
    } catch(e){console.debug(e);}

On Safari and FF the console prints


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:

The xml file is here:

Attachments (1)

feed.xml (184.0 KB) - added by juzzam 12 years ago.

Download all attachments as: .zip

Change History (11)

Changed 12 years ago by juzzam

Attachment: feed.xml added

comment:1 Changed 12 years ago by juzzam

Please assign to Eugene Lazutkin - elazutkin. This is my first bug submission - sorry for not opening it against him in the first place.

comment:2 Changed 12 years ago by James Burke

Owner: changed from anonymous to Eugene Lazutkin

comment:3 Changed 12 years ago by Eugene Lazutkin

Component: GeneralHTML
Description: modified (diff)
Milestone: tbdfuture
Status: newassigned

comment:4 Changed 12 years ago by Eugene Lazutkin

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 Phil Bowles

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...


essentially if your href is just a relative href="somelink"..WORKING browsers will correctly return "somelink" from attr('href') whereas IE will (stupidly) return ""

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 Phil Bowles

This nasty hack just worked cross-browser for me if you are having the same problem...

function fixlinks(scope){
		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 10 years ago by kadudare

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:

	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: , and here is my XML file:

Thanks in advance!

comment:8 Changed 10 years ago by ben hockey

#15152 is a duplicate of this ticket.

comment:9 Changed 10 years ago by kadudare

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 6 years ago by dylan

Milestone: future1.12
Resolution: patchwelcome
Status: assignedclosed

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.

Note: See TracTickets for help on using tickets.