On Feb 14, 12:54 pm, "raf" <[EMAIL PROTECTED]> wrote:
> I discovered the problem. It was the (seemingly unnecessary)
> function:
>      Object.prototype.getElementsByClassName = function

You should also check to see if that property has already been defined
before stomping on it - Firefox 3 will have (has?) a native
getElementsByClassName method which will likely run much, much faster
than any javascript-based equivalent.  You should check to see if it
already exists and leverage it if it does.

If you intend to re-use your code in a library, It it good practice to
name-space your variables - especially if you are going to use them
with other libraries.


> Once I commented this out and thereby used the prototype library
> function (method) of the same name all worked well.
>
> I guess the moral is that one should not use Object.prototype.
>
> Since I don't fully understand the issue(s) here, I'm wondering where
> I would go to read about the use and abuse of the XXX.prototype method/
> property?

It's pretty simple: don't mess with built-in object prototypes unless
you fully understand the consequences of doing so.  Mess with the
prototype property of your own objects all you like.

Perhaps you should spend some time learning about prototypes, they are
very powerful and at the core of javascript's (parasitic) inheritance
model.

<URL: http://javascript.crockford.com/prototypal.html >


--
Rob


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to