1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:57:35 +00:00

LibWeb: Handle currently ignored WebIDL::ExceptionOr<T>s

This commit is contained in:
Linus Groh 2022-10-30 17:50:04 +00:00
parent f01d90aa63
commit acfb546048
38 changed files with 153 additions and 149 deletions

View file

@ -45,7 +45,7 @@ JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&)
auto audio = DOM::create_element(document, HTML::TagNames::audio, Namespace::HTML);
// 3. Set an attribute value for audio using "preload" and "auto".
audio->set_attribute(HTML::AttributeNames::preload, "auto"sv);
MUST(audio->set_attribute(HTML::AttributeNames::preload, "auto"sv));
auto src_value = vm.argument(0);
@ -53,7 +53,7 @@ JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&)
// (This will cause the user agent to invoke the object's resource selection algorithm before returning.)
if (!src_value.is_undefined()) {
auto src = TRY(src_value.to_string(vm));
audio->set_attribute(HTML::AttributeNames::src, move(src));
MUST(audio->set_attribute(HTML::AttributeNames::src, move(src)));
}
// 5. Return audio.

View file

@ -47,13 +47,13 @@ JS::ThrowCompletionOr<JS::Object*> ImageConstructor::construct(FunctionObject&)
// 3. If width is given, then set an attribute value for img using "width" and width.
if (vm.argument_count() > 0) {
u32 width = TRY(vm.argument(0).to_u32(vm));
image_element->set_attribute(HTML::AttributeNames::width, String::formatted("{}", width));
MUST(image_element->set_attribute(HTML::AttributeNames::width, String::formatted("{}", width)));
}
// 4. If height is given, then set an attribute value for img using "height" and height.
if (vm.argument_count() > 1) {
u32 height = TRY(vm.argument(1).to_u32(vm));
image_element->set_attribute(HTML::AttributeNames::height, String::formatted("{}", height));
MUST(image_element->set_attribute(HTML::AttributeNames::height, String::formatted("{}", height)));
}
// 5. Return img.

View file

@ -52,21 +52,21 @@ JS::ThrowCompletionOr<JS::Object*> OptionConstructor::construct(FunctionObject&)
auto text = TRY(vm.argument(0).to_string(vm));
if (!text.is_empty()) {
auto new_text_node = vm.heap().allocate<DOM::Text>(realm, document, text);
option_element->append_child(*new_text_node);
MUST(option_element->append_child(*new_text_node));
}
}
// 4. If value is given, then set an attribute value for option using "value" and value.
if (vm.argument_count() > 1) {
auto value = TRY(vm.argument(1).to_string(vm));
option_element->set_attribute(HTML::AttributeNames::value, value);
MUST(option_element->set_attribute(HTML::AttributeNames::value, value));
}
// 5. If defaultSelected is true, then set an attribute value for option using "selected" and the empty string.
if (vm.argument_count() > 2) {
auto default_selected = vm.argument(2).to_boolean();
if (default_selected) {
option_element->set_attribute(HTML::AttributeNames::selected, "");
MUST(option_element->set_attribute(HTML::AttributeNames::selected, ""));
}
}