diff options
author | Linus Groh <mail@linusgroh.de> | 2021-09-24 12:57:04 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-24 12:57:04 +0200 |
commit | a1a164e6b8d107f9bc5edd58b210b34c096d6b66 (patch) | |
tree | 170b5257659f2159f40e09e7f7d673d9ec8c9a87 /Meta | |
parent | 09bdb00eb00c13b39df59a30e793e62cd23638e3 (diff) | |
download | serenity-a1a164e6b8d107f9bc5edd58b210b34c096d6b66.zip |
LibWeb: Return undefined from generated setters, not an empty value
These now crash as VM::call() uses ThrowExceptionOr<T>, 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 <lukew@serenityos.org>
Diffstat (limited to 'Meta')
-rw-r--r-- | Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp | 7 |
1 files 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(); } )~~~"); } |