mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 10:12:25 -05:00
LibJS: Add Object::has_property()
Like Object::has_own_property() but going down the prototype chain.
This commit is contained in:
parent
4cdd802927
commit
62671bea68
Notes:
sideshowbarker
2024-07-19 07:08:29 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/62671bea685 Pull-request: https://github.com/SerenityOS/serenity/pull/2047 Reviewed-by: https://github.com/awesomekling
2 changed files with 13 additions and 0 deletions
|
@ -381,6 +381,17 @@ void Object::visit_children(Cell::Visitor& visitor)
|
|||
visitor.visit(value);
|
||||
}
|
||||
|
||||
bool Object::has_property(const FlyString& property_name) const
|
||||
{
|
||||
const Object* object = this;
|
||||
while (object) {
|
||||
if (object->has_own_property(property_name))
|
||||
return true;
|
||||
object = object->prototype();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Object::has_own_property(const FlyString& property_name) const
|
||||
{
|
||||
bool ok;
|
||||
|
|
|
@ -96,7 +96,9 @@ public:
|
|||
void set_prototype(Object*);
|
||||
bool has_prototype(const Object* prototype) const;
|
||||
|
||||
bool has_property(const FlyString& property_name) const;
|
||||
bool has_own_property(const FlyString& property_name) const;
|
||||
|
||||
enum class PreferredType {
|
||||
Default,
|
||||
String,
|
||||
|
|
Loading…
Add table
Reference in a new issue