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

LibJS: Add the Object.getOwnPropertySymbols method

This commit is contained in:
Idan Horowitz 2021-06-12 17:41:13 +03:00 committed by Linus Groh
parent a2da3f97ef
commit bd9e20ef79
5 changed files with 44 additions and 15 deletions

View file

@ -307,23 +307,25 @@ MarkedValueList Object::get_own_properties(PropertyKind kind, bool only_enumerab
return properties;
}
for (auto& entry : m_indexed_properties) {
auto value_and_attributes = entry.value_and_attributes(const_cast<Object*>(this));
if (only_enumerable_properties && !value_and_attributes.attributes.is_enumerable())
continue;
if (return_type != GetOwnPropertyReturnType::SymbolOnly) {
for (auto& entry : m_indexed_properties) {
auto value_and_attributes = entry.value_and_attributes(const_cast<Object*>(this));
if (only_enumerable_properties && !value_and_attributes.attributes.is_enumerable())
continue;
if (kind == PropertyKind::Key) {
properties.append(js_string(vm(), String::number(entry.index())));
} else if (kind == PropertyKind::Value) {
properties.append(value_and_attributes.value);
} else {
auto* entry_array = Array::create(global_object());
entry_array->define_property(0, js_string(vm(), String::number(entry.index())));
entry_array->define_property(1, value_and_attributes.value);
properties.append(entry_array);
if (kind == PropertyKind::Key) {
properties.append(js_string(vm(), String::number(entry.index())));
} else if (kind == PropertyKind::Value) {
properties.append(value_and_attributes.value);
} else {
auto* entry_array = Array::create(global_object());
entry_array->define_property(0, js_string(vm(), String::number(entry.index())));
entry_array->define_property(1, value_and_attributes.value);
properties.append(entry_array);
}
if (vm().exception())
return MarkedValueList { heap() };
}
if (vm().exception())
return MarkedValueList { heap() };
}
auto add_property_to_results = [&](auto& property) {