1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

LibJS: Convert to_u32() to ThrowCompletionOr

This commit is contained in:
Idan Horowitz 2021-10-17 23:43:29 +03:00
parent f6a5ff7b00
commit cc94bba5c0
14 changed files with 32 additions and 69 deletions

View file

@ -47,16 +47,12 @@ JS::Value ImageConstructor::construct(FunctionObject&)
auto image_element = DOM::create_element(document, HTML::TagNames::img, Namespace::HTML);
if (vm().argument_count() > 0) {
u32 width = vm().argument(0).to_u32(global_object());
if (vm().exception())
return {};
u32 width = TRY_OR_DISCARD(vm().argument(0).to_u32(global_object()));
image_element->set_attribute(HTML::AttributeNames::width, String::formatted("{}", width));
}
if (vm().argument_count() > 1) {
u32 height = vm().argument(1).to_u32(global_object());
if (vm().exception())
return {};
u32 height = TRY_OR_DISCARD(vm().argument(1).to_u32(global_object()));
image_element->set_attribute(HTML::AttributeNames::height, String::formatted("{}", height));
}