From a1a164e6b8d107f9bc5edd58b210b34c096d6b66 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 24 Sep 2021 12:57:04 +0200 Subject: [PATCH] LibWeb: Return undefined from generated setters, not an empty value These now crash as VM::call() uses ThrowExceptionOr, which refuses to hold an empty JS::Value as its non-exception result. We only need to return an empty value when should_return_empty() says so for the return value of throw_dom_exception_if_needed(). Co-authored-by: Luke Wilde --- .../Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp index 9e48eb8ec8..c42dcab99a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp @@ -1739,12 +1739,15 @@ JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::@attribute.setter_callback@) } } else { attribute_generator.append(R"~~~( - [[maybe_unused]] auto retval = throw_dom_exception_if_needed(vm, global_object, [&] { return impl->set_@attribute.name:snakecase@(cpp_value); }); + auto result = throw_dom_exception_if_needed(vm, global_object, [&] { return impl->set_@attribute.name:snakecase@(cpp_value); }); + + if (should_return_empty(result)) + return JS::Value(); )~~~"); } attribute_generator.append(R"~~~( - return {}; + return JS::js_undefined(); } )~~~"); }