Changeset 9675

Show
Ignore:
Timestamp:
07/16/07 08:10:00 (18 months ago)
Author:
blowery
Message:

refs #3769, refs #3742. Revert change to enable native array iteration methods
on Safari3. The change fails the existing unit tests for array.js, and it does
not appear that Safari3's implementation is sufficient for dojo's forEach
contract. Specifically, forEach is not defined on String objects or null /
undefined values, so call against those types fail with a TypeError?.

We could insert an adapter that used the fast path on Safari3 when available
and fell back to the default Dojo implementation otherwise, but we'd need to
vet that technique with performance testing. For now, I'm just reverting the
change and we can figure out what we'd like to do long term.. later.

Location:
dojo/trunk
Files:
1 removed
1 modified

Legend:

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

    r9616 r9675  
    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         }; 
    126        if(Array.forEach){ 
    137                // fast, if we can 
     8                var tn = ["indexOf", "lastIndexOf", "every", "some", "forEach", "filter", "map"]; 
    149                for(var x=0; x<tn.length; x++){ 
    1510                        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 
    2111                } 
    2212        }else{