public
Description: Prototype JavaScript framework
Homepage: http://prototypejs.org/
Clone URL: git://github.com/sstephenson/prototype.git
Improve NodeList detection for Safari's $A function. [#187 state:resolved]
Thu Jul 17 13:31:28 -0700 2008
commit  d1c6b0199bfe6d1ef13cf207455307a424d05393
tree    f8d25bda86d3aadd0d27f4594dc74e8bbc62044f
parent  9f00912b52125f3bdaee4aa544a885a1cae993e0
...
 
 
1
2
3
...
1
2
3
4
5
0
@@ -1,3 +1,5 @@
0
+* Improve NodeList detection for Safari's $A function. [Garrett Smith, jddalton]
0
+
0
 * Use different tactic to sniff for Opera in order to avoid false positives in IE. [Tobie Langel, jddalton]
0
 
0
 * Optimize Function#bind and Function#bindAsEventListener to avoid using Array#concat when only the context argument is given. [kangax]
...
8
9
10
11
12
13
 
 
 
 
 
 
 
14
15
16
...
8
9
10
 
 
 
11
12
13
14
15
16
17
18
19
20
0
@@ -8,9 +8,13 @@ function $A(iterable) {
0
 
0
 if (Prototype.Browser.WebKit) {
0
   $A = function(iterable) {
0
- if (!iterable) return [];
0
- if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') &&
0
- iterable.toArray) return iterable.toArray();
0
+ if (!iterable) return [];
0
+ // In Safari, only use the `toArray` method if it's not a NodeList.
0
+ // A NodeList is a function, has an function `item` property, and a numeric
0
+ // `length` property. Adapted from Google Doctype.
0
+ if (!(typeof iterable === 'function' && typeof iterable.length ===
0
+ 'number' && typeof iterable.item === 'function') && iterable.toArray)
0
+ return iterable.toArray();
0
     var length = iterable.length || 0, results = new Array(length);
0
     while (length--) results[length] = iterable[length];
0
     return results;

Comments

    No one has commented yet.