On 9/11/06, Nic Williams <[EMAIL PROTECTED]> wrote:

> So would it still be useful for a revised $() function?

There is no need to change $().

What you see is the legacy of Netscape taking a stride away from the
ECMAScript standard.

Netscape's JS engine treated (and still treats) strings as array of
strings to allow things like "test"[0] to return "t".

I do not know the internal working, but from observation:

When using "this" in a function defined in String.prototype, "this"
behaves like a string, when the context of the use requires a string.
And it looks like the engine knows document.getElementById() requires
a string. If the context does not require a string, like when using
"this" as a function argument to a user defined function, "this"
evaluates to an array of chars.

Therefore, the error is not with $(). Besides the before mentioned
$(String(this)), $(this.valueOf()) will work as well.

--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to