mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 16:19:23 +00:00
LibJS: Resolve the correct this value for calls in with statements
This commit is contained in:
parent
3a8dd3e78d
commit
28e552f853
Notes:
sideshowbarker
2024-07-17 08:09:56 +09:00
Author: https://github.com/davidot
Commit: 28e552f853
Pull-request: https://github.com/SerenityOS/serenity/pull/14904
Reviewed-by: https://github.com/linusg
1 changed files with 7 additions and 1 deletions
|
@ -339,9 +339,15 @@ ThrowCompletionOr<CallExpression::ThisAndCallee> CallExpression::compute_this_an
|
||||||
return ThisAndCallee { this_value, callee };
|
return ThisAndCallee { this_value, callee };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Value this_value = js_undefined();
|
||||||
|
if (callee_reference.is_environment_reference()) {
|
||||||
|
if (Object* base_object = callee_reference.base_environment().with_base_object(); base_object != nullptr)
|
||||||
|
this_value = base_object;
|
||||||
|
}
|
||||||
|
|
||||||
// [[Call]] will handle that in non-strict mode the this value becomes the global object
|
// [[Call]] will handle that in non-strict mode the this value becomes the global object
|
||||||
return ThisAndCallee {
|
return ThisAndCallee {
|
||||||
js_undefined(),
|
this_value,
|
||||||
callee_reference.is_unresolvable()
|
callee_reference.is_unresolvable()
|
||||||
? TRY(m_callee->execute(interpreter, global_object)).release_value()
|
? TRY(m_callee->execute(interpreter, global_object)).release_value()
|
||||||
: TRY(callee_reference.get_value(global_object))
|
: TRY(callee_reference.get_value(global_object))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue