Changeset 9615

Show
Ignore:
Timestamp:
07/12/07 13:34:03 (18 months ago)
Author:
blowery
Message:

fixes #3742. add support for native array iteration methods for safari3

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/_base/array.js

    r9589 r9615  
    44(function(){ 
    55        var d = dojo; 
     6        var tn = ["indexOf", "lastIndexOf", "every", "some", "forEach", "filter", "map"]; 
     7        var makeCall = function(fn){ 
     8                return function(a){ 
     9                        a[fn].apply(a, Array.prototype.slice.call(arguments, 1)); 
     10                } 
     11        }; 
    612        if(Array.forEach){ 
    713                // fast, if we can 
    8                 var tn = ["indexOf", "lastIndexOf", "every", "some", "forEach", "filter", "map"]; 
    914                for(var x=0; x<tn.length; x++){ 
    1015                        d[tn[x]] = Array[tn[x]]; 
     16                } 
     17        }else if(Array.prototype.forEach){ 
     18                // safari3 only exposes the fast methods on the prototype 
     19                for(var x=0; x<tn.length; x++) { 
     20                        d[tn[x]] = makeCall(tn[x]);  // have to do this to bind the looped var 
    1121                } 
    1222        }else{