From 7a1666f77ee878a98f770b0d439ceb75f49ff1e2 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 21 Nov 2009 13:08:01 -0500 Subject: Fix for lack of 'apply' method of IE6 native functions --- lib/js/urweb.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 62f94f52..ba1e9625 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -891,8 +891,27 @@ function exec1(env, stack, e) { 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; -- cgit v1.2.3