mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:57:34 +00:00
LibJS: Remove Proxy() argument count check
Let's just treat missing arguments as undefined and throw with 'target/handler must be object' - this is more JavaScript-y.
This commit is contained in:
parent
5ff85abe8c
commit
e39dd65cf0
3 changed files with 8 additions and 8 deletions
|
@ -128,7 +128,6 @@
|
||||||
M(ProxySetPrototypeOfNonExtensible, "Proxy handler's setPrototypeOf trap violates " \
|
M(ProxySetPrototypeOfNonExtensible, "Proxy handler's setPrototypeOf trap violates " \
|
||||||
"invariant: the argument must match the prototype of the target if the " \
|
"invariant: the argument must match the prototype of the target if the " \
|
||||||
"target is non-extensible") \
|
"target is non-extensible") \
|
||||||
M(ProxyTwoArguments, "Proxy constructor requires at least two arguments") \
|
|
||||||
M(ReduceNoInitial, "Reduce of empty array with no initial value") \
|
M(ReduceNoInitial, "Reduce of empty array with no initial value") \
|
||||||
M(ReferenceNullishDeleteProperty, "Cannot delete property '{}' of {}") \
|
M(ReferenceNullishDeleteProperty, "Cannot delete property '{}' of {}") \
|
||||||
M(ReferenceNullishGetProperty, "Cannot get property '{}' of {}") \
|
M(ReferenceNullishGetProperty, "Cannot get property '{}' of {}") \
|
||||||
|
|
|
@ -38,11 +38,6 @@ Value ProxyConstructor::call()
|
||||||
Value ProxyConstructor::construct(Function&)
|
Value ProxyConstructor::construct(Function&)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
if (vm.argument_count() < 2) {
|
|
||||||
vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyTwoArguments);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto target = vm.argument(0);
|
auto target = vm.argument(0);
|
||||||
auto handler = vm.argument(1);
|
auto handler = vm.argument(1);
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,17 @@ test("constructs properly", () => {
|
||||||
test("constructor argument count", () => {
|
test("constructor argument count", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new Proxy();
|
new Proxy();
|
||||||
}).toThrowWithMessage(TypeError, "Proxy constructor requires at least two arguments");
|
}).toThrowWithMessage(
|
||||||
|
TypeError,
|
||||||
|
"Expected target argument of Proxy constructor to be object, got undefined"
|
||||||
|
);
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new Proxy({});
|
new Proxy({});
|
||||||
}).toThrowWithMessage(TypeError, "Proxy constructor requires at least two arguments");
|
}).toThrowWithMessage(
|
||||||
|
TypeError,
|
||||||
|
"Expected handler argument of Proxy constructor to be object, got undefined"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("constructor requires objects", () => {
|
test("constructor requires objects", () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue