Hi guys. I'm new in prototypejs and script.aculo.

But, lets consider Andrew Dupont's example again:

var f = new String("foo");
alert($(f)) //-> foo
alert(document.getElementById('foo')) //-> [object HTMLElement]

It has cause:

"When String( ) is used as a constructor with the new operator, it
returns a String object, which holds the string s or the string
representation of s. When the String( ) constructor is used without
the new operator, it simply converts s to a primitive string and
returns the converted value."

it's mean:

alert(typeof new String()) //-> object
alert(typeof String()) //-> string

Possible, it will be better to redefine $ like this:

function $(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i <
length; i++)
    return elements;
  if (typeof element == 'string' || element instanceof String) //<-
    element = document.getElementById(element);
  return Element.extend(element);

Or it isn't good idea. What do you think?

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to