1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

LibJS: Object::put() shouldn't create own properties on prototype chain

Unless there is a setter present on the prototype chain, put() should
only set own properties on the object itself.

Fixes #1588.
This commit is contained in:
Andreas Kling 2020-04-02 21:34:31 +02:00
parent a62230770b
commit 99aab4470a
2 changed files with 10 additions and 2 deletions

View file

@ -133,6 +133,8 @@ Optional<Value> Object::get(const FlyString& property_name) const
void Object::put(const FlyString& property_name, Value value)
{
// If there's a setter in the prototype chain, we go to the setter.
// Otherwise, it goes in the own property storage.
Object* object = this;
while (object) {
auto metadata = object->shape().lookup(property_name);
@ -147,8 +149,6 @@ void Object::put(const FlyString& property_name, Value value)
interpreter.pop_call_frame();
return;
}
if (object->put_own_property(*this, property_name, value))
return;
}
object = object->prototype();
}