summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
index 3260bba7cc..9acff1182c 100644
--- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
@@ -33,26 +33,25 @@ ImageConstructor::~ImageConstructor()
{
}
-JS::Value ImageConstructor::call()
+JS::ThrowCompletionOr<JS::Value> ImageConstructor::call()
{
- vm().throw_exception<JS::TypeError>(global_object(), JS::ErrorType::ConstructorWithoutNew, "Image");
- return {};
+ return vm().throw_completion<JS::TypeError>(global_object(), JS::ErrorType::ConstructorWithoutNew, "Image");
}
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-image
-JS::Value ImageConstructor::construct(FunctionObject&)
+JS::ThrowCompletionOr<JS::Object*> ImageConstructor::construct(FunctionObject&)
{
auto& window = static_cast<WindowObject&>(global_object());
auto& document = window.impl().associated_document();
auto image_element = DOM::create_element(document, HTML::TagNames::img, Namespace::HTML);
if (vm().argument_count() > 0) {
- u32 width = TRY_OR_DISCARD(vm().argument(0).to_u32(global_object()));
+ u32 width = TRY(vm().argument(0).to_u32(global_object()));
image_element->set_attribute(HTML::AttributeNames::width, String::formatted("{}", width));
}
if (vm().argument_count() > 1) {
- u32 height = TRY_OR_DISCARD(vm().argument(1).to_u32(global_object()));
+ u32 height = TRY(vm().argument(1).to_u32(global_object()));
image_element->set_attribute(HTML::AttributeNames::height, String::formatted("{}", height));
}