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>
This commit is contained in:
Linus Groh 2021-09-24 12:57:04 +02:00
parent 09bdb00eb0
commit a1a164e6b8
Notes: sideshowbarker 2024-07-18 03:30:16 +09:00

View file

@ -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();
}
)~~~");
}