mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
LibJS: Capture values as handles in Promise.prototype.finally callbacks
This commit is contained in:
parent
47cdd90836
commit
7feeb2df0d
1 changed files with 4 additions and 4 deletions
|
@ -111,9 +111,9 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
|
||||||
auto* promise = TRY(promise_resolve(global_object, constructor, result));
|
auto* promise = TRY(promise_resolve(global_object, constructor, result));
|
||||||
|
|
||||||
// iii. Let returnValue be a new Abstract Closure with no parameters that captures value and performs the following steps when called:
|
// iii. Let returnValue be a new Abstract Closure with no parameters that captures value and performs the following steps when called:
|
||||||
auto return_value = [value](auto&, auto&) -> ThrowCompletionOr<Value> {
|
auto return_value = [value_handle = make_handle(value)](auto&, auto&) -> ThrowCompletionOr<Value> {
|
||||||
// 1. Return value.
|
// 1. Return value.
|
||||||
return value;
|
return value_handle.value();
|
||||||
};
|
};
|
||||||
|
|
||||||
// iv. Let valueThunk be ! CreateBuiltinFunction(returnValue, 0, "", « »).
|
// iv. Let valueThunk be ! CreateBuiltinFunction(returnValue, 0, "", « »).
|
||||||
|
@ -139,9 +139,9 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
|
||||||
auto* promise = TRY(promise_resolve(global_object, constructor, result));
|
auto* promise = TRY(promise_resolve(global_object, constructor, result));
|
||||||
|
|
||||||
// iii. Let throwReason be a new Abstract Closure with no parameters that captures reason and performs the following steps when called:
|
// iii. Let throwReason be a new Abstract Closure with no parameters that captures reason and performs the following steps when called:
|
||||||
auto throw_reason = [reason](auto&, auto&) -> ThrowCompletionOr<Value> {
|
auto throw_reason = [reason_handle = make_handle(reason)](auto&, auto&) -> ThrowCompletionOr<Value> {
|
||||||
// 1. Return ThrowCompletion(reason).
|
// 1. Return ThrowCompletion(reason).
|
||||||
return throw_completion(reason);
|
return throw_completion(reason_handle.value());
|
||||||
};
|
};
|
||||||
|
|
||||||
// iv. Let thrower be ! CreateBuiltinFunction(throwReason, 0, "", « »).
|
// iv. Let thrower be ! CreateBuiltinFunction(throwReason, 0, "", « »).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue