#1113 new

Enhancement to $A(iterable) utility function.

Reported by bjc | August 8th, 2010 @ 09:35 AM

Currently the $A(iter) function uses an explictly created array when it contains a "length" property.

This code can be minimalized by using the "Array.prototype.slice(iterable, 0);" function to something like:

function $A(iterable) {
// Safari <2.0.4 crashes when accessing property of a node list with property accessor. // It nevertheless works fine with in operator, which is why we use it here if ('toArray' in Object(iterable)) return iterable.toArray(); return Array.prototype.slice(iterable, 0); }

Note I have only tested this on chrome and safari (v8 & javascriptcore engines) which are somewhat more modern than those listed as compatible with prototypejs.

If this can be verified to work with all the browsers and versions listed on the compatability page I think this would be a clever and concise addition to the library.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket