1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:17:35 +00:00

LibJS: Let Object::get_own_properties() return both strings and symbols

The new default return_type argument is GetOwnPropertyReturnType::All,
which returns properties with both string and symbol keys (which is also
the default for [[OwnPropertyKeys]]). This means that in some cases we
need to iterate the ordered property table twice, as we don't store
string and symbol properties separately but symbols must - there's
certainly room for (performance) improvements here. On the other hand
this makes Reflect.ownKeys() return symbol properties now :^)
This commit is contained in:
Linus Groh 2021-04-05 19:17:40 +02:00 committed by Andreas Kling
parent 1416027486
commit abc7b31079
3 changed files with 38 additions and 20 deletions

View file

@ -74,6 +74,7 @@ public:
};
enum class GetOwnPropertyReturnType {
All,
StringOnly,
SymbolOnly,
};
@ -96,7 +97,7 @@ public:
virtual bool put(const PropertyName&, Value, Value receiver = {});
Value get_own_property(const PropertyName&, Value receiver) const;
Value get_own_properties(PropertyKind, bool only_enumerable_properties = false, GetOwnPropertyReturnType = GetOwnPropertyReturnType::StringOnly) const;
Value get_own_properties(PropertyKind, bool only_enumerable_properties = false, GetOwnPropertyReturnType = GetOwnPropertyReturnType::All) const;
Value get_enumerable_own_property_names(PropertyKind) const;
virtual Optional<PropertyDescriptor> get_own_property_descriptor(const PropertyName&) const;
Value get_own_property_descriptor_object(const PropertyName&) const;