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

LibJS: Make PrimitiveString::utf8_string() infallible

Work towards #20449.
This commit is contained in:
Andreas Kling 2023-08-08 19:17:55 +02:00
parent 7849950383
commit c084269e5f
29 changed files with 79 additions and 93 deletions

View file

@ -1573,7 +1573,7 @@ void Element::enqueue_a_custom_element_callback_reaction(FlyString const& callba
VERIFY(!arguments.is_empty());
auto& attribute_name_value = arguments.first();
VERIFY(attribute_name_value.is_string());
auto attribute_name = attribute_name_value.as_string().utf8_string().release_allocated_value_but_fixme_should_propagate_errors();
auto attribute_name = attribute_name_value.as_string().utf8_string();
// 2. If definition's observed attributes does not contain attributeName, then return.
if (!definition->observed_attributes().contains_slow(attribute_name))

View file

@ -166,9 +166,7 @@ private:
WebIDL::ExceptionOr<void> serialize_string(Vector<u32>& vector, JS::PrimitiveString const& primitive_string)
{
auto string = TRY(Bindings::throw_dom_exception_if_needed(m_vm, [&primitive_string]() {
return primitive_string.utf8_string();
}));
auto string = primitive_string.utf8_string();
TRY(serialize_string(vector, string));
return {};
}

View file

@ -52,7 +52,7 @@ WebIDL::ExceptionOr<String> serialize_javascript_value_to_json_string(JS::VM& vm
VERIFY(result.is_string());
// 4. Return result.
return TRY(result.as_string().utf8_string());
return result.as_string().utf8_string();
}
// https://infra.spec.whatwg.org/#serialize-a-javascript-value-to-json-bytes

View file

@ -3131,7 +3131,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> transform_stream_default_
TRY(transform_stream_error(stream, reason));
// 2. Throw readable.[[storedError]].
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, TRY(readable->stored_error().as_string().utf8_string_view()) };
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, readable->stored_error().as_string().utf8_string() };
});
return WebIDL::create_resolved_promise(realm, react_result);