mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +02:00
LibJS: Make more use of Value::is and Value::as_if in JS runtime
This commit is contained in:
committed by
Shannon Booth
parent
cadba4c0e7
commit
d7e828a366
Notes:
github-actions[bot]
2026-02-27 16:20:55 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/d7e828a3661 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8208 Reviewed-by: https://github.com/shannonbooth ✅
@@ -136,14 +136,13 @@ void AsyncFunctionDriverWrapper::continue_async_execution(VM& vm, Value value, b
|
||||
auto promise_value = result.value;
|
||||
if (result.done) {
|
||||
// When returning a promise, we need to unwrap it.
|
||||
if (promise_value.is_object() && is<Promise>(promise_value.as_object())) {
|
||||
auto& returned_promise = static_cast<Promise&>(promise_value.as_object());
|
||||
if (returned_promise.state() == Promise::State::Fulfilled) {
|
||||
m_top_level_promise->fulfill(returned_promise.result());
|
||||
if (auto returned_promise = promise_value.as_if<Promise>()) {
|
||||
if (returned_promise->state() == Promise::State::Fulfilled) {
|
||||
m_top_level_promise->fulfill(returned_promise->result());
|
||||
return {};
|
||||
}
|
||||
if (returned_promise.state() == Promise::State::Rejected)
|
||||
return throw_completion(returned_promise.result());
|
||||
if (returned_promise->state() == Promise::State::Rejected)
|
||||
return throw_completion(returned_promise->result());
|
||||
|
||||
// The promise is still pending but there's nothing more to do here.
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user