On Apr 13, 12:51 pm, mr_justin <gro...@jperkins.otherinbox.com> wrote:
> Trying out the RC2 and ran into some trouble with existing code
> working with the new version of prototype.
> Old code: $A('one', 'two', 'three')
> This no longer works and requires either to wrap the arguments in
> square brackets or use the $w() method. This change doesn't seem to be
> documented, but on an existing (large) project, the impact is quite
> large. Not on the scale of the Hash change in 1.6.0, but still, big
> enough to give pause.
> Is it safe to just go ahead and start updating our code to use the new
> syntax or was this issue introduced inadvertently? Here's the
> changeset that introduced the 
> issue:http://github.com/sstephenson/prototype/commit/1a375daea249ee6a42a1dd...

This is a regression. $A('foo') should return ['f', 'o', 'o'] (since
'foo' is a string and strings are extended with `toArray` which
delegates to `split('')`, essentuially returning an array of string
characters). AFAIK, arguments other than first were never taken into
account, so `$A('one', 'two', 'three')`, as in your example, should
produce - ['o', 'n', 'e']. The fact that non-object values now throw
errors is a clear mistake on our part. We need to explicitly type-
convert any value to an object before attempting to use it on RHS of

function $A(iterable) {
  if (!iterable) return [];
  if ('toArray' in Object(iterable)) return iterable.toArray();
  var length = iterable.length || 0, results = new Array(length);
  while (length--) results[length] = iterable[length];
  return results;

Hope this helps.

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