mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 08:27:35 +00:00
LibJS: Stop overwriting existing indexed accessors in define_accessor
The previous implementation only checked the shape, ignoring existing accessors when using number property names.
This commit is contained in:
parent
6352a33ed2
commit
623eadb44e
1 changed files with 2 additions and 7 deletions
|
@ -591,13 +591,8 @@ bool Object::define_accessor(const PropertyName& property_name, Function* getter
|
||||||
{
|
{
|
||||||
VERIFY(property_name.is_valid());
|
VERIFY(property_name.is_valid());
|
||||||
|
|
||||||
Accessor* accessor { nullptr };
|
auto existing_property = get_own_property(property_name, this, true);
|
||||||
auto property_metadata = shape().lookup(property_name.to_string_or_symbol());
|
auto* accessor = existing_property.is_accessor() ? &existing_property.as_accessor() : nullptr;
|
||||||
if (property_metadata.has_value()) {
|
|
||||||
auto existing_property = get_direct(property_metadata.value().offset);
|
|
||||||
if (existing_property.is_accessor())
|
|
||||||
accessor = &existing_property.as_accessor();
|
|
||||||
}
|
|
||||||
if (!accessor) {
|
if (!accessor) {
|
||||||
accessor = Accessor::create(vm(), getter, setter);
|
accessor = Accessor::create(vm(), getter, setter);
|
||||||
bool definition_success = define_property(property_name, accessor, attributes, throw_exceptions);
|
bool definition_success = define_property(property_name, accessor, attributes, throw_exceptions);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue