changeset 1035:f87d0fedc54c

Fix for lack of 'apply' method of IE6 native functions
author Adam Chlipala <adamc@hcoop.net>
date Sat, 21 Nov 2009 13:08:01 -0500
parents a779402841f6
children e214ac93d73e
files lib/js/urweb.js
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/js/urweb.js	Tue Nov 17 12:44:14 2009 -0500
+++ b/lib/js/urweb.js	Sat Nov 21 13:08:01 2009 -0500
@@ -891,8 +891,27 @@
       case "f":
         fr.args[fr.pos++] = v;
         if (fr.a == null) {
+          var res;
           stack = stack.next;
-          e = {c: "c", v: fr.f.apply(null, fr.args)};
+
+          if (fr.f.apply)
+            res = fr.f.apply(null, fr.args);
+          else if (fr.args.length == 0)
+            res = fr.f();
+          else if (fr.args.length == 1)
+            res = fr.f(fr.args[0]);
+          else if (fr.args.length == 2)
+            res = fr.f(fr.args[0], fr.args[1]);
+          else if (fr.args.length == 3)
+            res = fr.f(fr.args[0], fr.args[1], fr.args[2]);
+          else if (fr.args.length == 4)
+            res = fr.f(fr.args[0], fr.args[1], fr.args[2], fr.args[3]);
+          else if (fr.args.length == 5)
+            res = fr.f(fr.args[0], fr.args[1], fr.args[2], fr.args[3], fr.args[4]);
+          else
+            whine("Native function has " + fr.args.length + " args, but there is no special case for that count.");
+
+          e = {c: "c", v: res};
           if (usedK) return null;
         } else {
           e = fr.a.data;