mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 04:37:55 +00:00
LibJS: Oops, "instanceof" was backwards!
Fix the "instanceof" operator to check if the constructor's prototype property occurs anywhere in the prototype chain of the instance object. This patch also adds Object.setPrototypeOf() to make it possible to create a test for this bug. Thanks to DexesTTP for pointing this out! :^)
This commit is contained in:
@@ -44,6 +44,15 @@ Object::~Object()
|
||||
{
|
||||
}
|
||||
|
||||
bool Object::has_prototype(const Object* prototype) const
|
||||
{
|
||||
for (auto* object = m_prototype; object; object = object->prototype()) {
|
||||
if (object == prototype)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<Value> Object::get_own_property(const Object& this_object, const FlyString& property_name) const
|
||||
{
|
||||
auto value_here = m_properties.get(property_name);
|
||||
|
||||
Reference in New Issue
Block a user