mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02: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:
Notes:
sideshowbarker
2024-07-19 08:05:26 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/82ca7ae1f80
@@ -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