Wow I hate the attribute model, so broken heh.

What is wrong with the native "getAttribute" method, is there anything
different going on here?

Cheers,
       Matt

On Sep 13, 3:02 pm, Yanick <[EMAIL PROTECTED]> wrote:
> I don't know if anyone has encountered this problem before, but I was
> reading nodes from an XML document (ajax response) and I tried the
> Element.readAttribute function instead of my own home brewed
> algorithm. (This Web application goes all the way from before there
> was such function in the Prototype library...) Anyway, firefox didn't
> complain, but IE seemed to do so. Here's what I did to resolve this
> issue :
>
> 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);
>   },
>
> I'm sorry I'm not the best guy to provide more test with this matter,
> but I'm pretty sure some of you already have the proper setup to do
> them. So I'm leaving this into your more capable hands.
>
> Thank you.
>
> yanick


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to