Index: src/proxy.js |
diff --git a/src/proxy.js b/src/proxy.js |
index a51f09ae50ff3eee75840e970413ddd75909d9a9..d93b58ac6a4b9e281347b733a0a98eca9b630d9d 100644 |
--- a/src/proxy.js |
+++ b/src/proxy.js |
@@ -32,7 +32,10 @@ var $Proxy = global.Proxy |
$Proxy.create = function(handler, proto) { |
if (!IS_SPEC_OBJECT(handler)) |
throw MakeTypeError("handler_non_object", ["create"]) |
- if (!IS_SPEC_OBJECT(proto)) proto = null // Mozilla does this... |
+ if (IS_UNDEFINED(proto)) |
+ proto = null |
+ else if (!(IS_SPEC_OBJECT(proto) || proto === null)) |
+ throw MakeTypeError("proto_non_object", ["create"]) |
return %CreateJSProxy(handler, proto) |
} |
@@ -43,18 +46,13 @@ $Proxy.createFunction = function(handler, callTrap, constructTrap) { |
throw MakeTypeError("trap_function_expected", ["createFunction", "call"]) |
var construct |
Michael Starzinger
2011/10/13 16:22:48
I think that "var" can be removed now.
rossberg
2011/10/24 15:59:49
Done.
|
if (IS_UNDEFINED(constructTrap)) { |
- construct = DerivedConstructTrap(callTrap) |
- } else if (IS_SPEC_FUNCTION(constructTrap)) { |
- construct = function() { |
- // Make sure the trap receives 'undefined' as this. |
- return %Apply(constructTrap, void 0, arguments, 0, %_ArgumentsLength()); |
- } |
- } else { |
+ constructTrap = DerivedConstructTrap(callTrap) |
+ } else if (!IS_SPEC_FUNCTION(constructTrap)) { |
throw MakeTypeError("trap_function_expected", |
["createFunction", "construct"]) |
} |
return %CreateJSFunctionProxy( |
- handler, callTrap, construct, $Function.prototype) |
+ handler, callTrap, constructTrap, $Function.prototype) |
} |