Skip to content

Commit

Permalink
LibJS: Fix this_value in native setters and getters
Browse files Browse the repository at this point in the history
This fixes getting values from double proxies:
var p = new Proxy(new Proxy([], {}), {});
p.length
  • Loading branch information
davidot authored and linusg committed Jun 22, 2021
1 parent 9d1fd40 commit f102b56
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Userland/Libraries/LibJS/Runtime/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ Value Object::get_own_property(const PropertyName& property_name, Value receiver
if (value_here.is_accessor())
return value_here.as_accessor().call_getter(receiver);
if (value_here.is_native_property())
return call_native_property_getter(value_here.as_native_property(), receiver);
return call_native_property_getter(value_here.as_native_property(), this);
}
return value_here;
}
Expand Down Expand Up @@ -937,9 +937,7 @@ bool Object::put_by_index(u32 property_index, Value value)
return true;
}
if (value_here.value.is_native_property()) {
// FIXME: Why doesn't put_by_index() receive the receiver value from put()?!
auto receiver = this;
call_native_property_setter(value_here.value.as_native_property(), receiver, value);
call_native_property_setter(value_here.value.as_native_property(), this, value);
return true;
}
}
Expand Down Expand Up @@ -976,7 +974,7 @@ bool Object::put(const PropertyName& property_name, Value value, Value receiver)
return true;
}
if (value_here.is_native_property()) {
call_native_property_setter(value_here.as_native_property(), receiver, value);
call_native_property_setter(value_here.as_native_property(), this, value);
return true;
}
}
Expand Down

0 comments on commit f102b56

Please sign in to comment.