mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
LibJS: Make it possible to reference the "this" value in JavaScript
This commit is contained in:
parent
401becb922
commit
fecbef4ffe
Notes:
sideshowbarker
2024-07-19 08:05:49 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/fecbef4ffe9
1 changed files with 3 additions and 0 deletions
|
@ -144,6 +144,9 @@ void Interpreter::set_variable(const FlyString& name, Value value, bool first_as
|
|||
|
||||
Optional<Value> Interpreter::get_variable(const FlyString& name)
|
||||
{
|
||||
if (name == "this")
|
||||
return this_value();
|
||||
|
||||
for (ssize_t i = m_scope_stack.size() - 1; i >= 0; --i) {
|
||||
auto& scope = m_scope_stack.at(i);
|
||||
auto value = scope.variables.get(name);
|
||||
|
|
Loading…
Add table
Reference in a new issue