John Resig wrote:
>> ok with ie55 and 6 but error with ie50
> 
> Now I remember why I opted not to support IE 5.0 :-(
> 
> --John


The thing is - IE5.0 doesn't support .apply AT ALL! So we've created a 
function to emulate it. It works fine for objects passed in as the first 
argument, but I don't really understand what it means to pass a string 
as the first argument - so if someone can explain, then maybe I could 
fix the emulation!

Here's the current fix:

if (typeof Function.apply != 'function') {
    Function.prototype.apply = function (o, a) {
       var r;
       if (!o) o = {};
       o.___apply = this;
       switch((a && a.length) || 0) {
          case 0 : r = o.___apply();
          break;
          case 1 : r = o.___apply(a[0]);
          break;
          case 2 : r = o.___apply(a[0], a[1]);
          break;
          case 3 : r = o.___apply(a[0], a[1], a[2]);
          break;
          case 4 : r = o.___apply(a[0], a[1], a[2], a[3]);
          break;
          case 5 : r = o.___apply(a[0], a[1], a[2], a[3], a[4]);
          break;
          case 6 : r = o.___apply(a[0], a[1], a[2], a[3], a[4], a[5]);
          break;
          default : for(var i = 0, s = ""; i < a.length; i++) {
             if(i != 0) s += ",";
             s += "a[" + i + "]";
             }
          r = eval("o.___apply(" + s + ")");
          }
       o.__apply = null;
       return r;
       }
    }

Cheers


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to