As described in this post : http://groups.google.ca/group/prototype-core/browse_thread/thread/64dd0e29596259dd/42892c969503de76
I ran into a little problem while trying to read node attributes from an XML document. A test case should not be necessary as pretty much any XML node returned from an AJAX request to an onComplete even will cause this issue.
Here is a "fixed" version of the code I've been using so far without any trouble. The modification is not extensive and should not cause any other issue, except for maybe having negative effects on performances (if any).
// @modified 2007-09-14 Yanick Rochon
readAttribute: function(element, name) {
//element = $(element); // IE doesn't like this line (is it really necessary ?)
if (Prototype.Browser.IE) {
// XML nodes in IE has an array name attributes. Each index
// is an object { name: [string], value: [mixed], ... }
if ( element.attributes && element.attributes.length ) {
// I'm sure some might find a better way to do this, but it works for now....
var attribute = $A(element.attributes).find(function(attribute) {return attribute.name==name; });
// if we do not return here, we might throw an exception, so rather return null if not found
return attribute ? attribute.value : null;
}
var t = Element._attributeTranslations.read;
if (t.values[name]) return t.values[name](element, name);
if (t.names[name]) name = t.names[name];
if (name.include(':')) {
return (!element.attributes || !element.attributes[name]) ? null :
element.attributes[name].value;
}
}
return element.getAttribute(name);
}