On Apr 9, 6:34 pm, Jason <jbo...@gmail.com> wrote:
> Starting with 1.6.1 RC2, I discovered that using Element#readAttribute
> with an attribute name of "store" causes IE7 to return a function
> instead of null when the property doesn't exist:
>  function() {
>       var a = update([this], arguments);
>       return __method.apply(null, a);
>     }
> This didn't happen in Firefox or IE8, only IE7.
> Can anyone confirm this?  Testing for null on this attribute was

Yes, I can confirm this.

> unpredictable across browsers.  My solution was to not use the
> attribute name "store".
> Is this a bug?

I would say yes, it's a bug, since `readAttribute`, IIRC, guarantees
to return either `null` or a string value. You'll be surprised but
there are about 50 (if not more) other names that will cause similar
outcome. The reason for this is that DOM in IE<8 is broken as designed
and Prototype is being careless with its "brokenness". `getAttribute`,
which `readAttribute` uses internally does not differentiate between
attributes and properties. Since prototype.js directly extends
elements with "Element" methods, all of them are mistakenly returned
by `getAttribute`:

typeof $(myElement).getAttribute('show'); // "function"

1.6.1RC2 introduced another method - `store` - and is exactly why
you're having this issue. This is, of course, yet another reason not
to extend native elements, but a temporary fix could be for a
`readAttribute` to ensure that only `null` or string value is allowed
to be returned (i.e. turning non-string values such as function to

I would also recommend not to introduce custom attributes when
including Prototype.

Could you file a bug?

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to