mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:47:34 +00:00
LibJS: Implement temporal AO SnapshotOwnProperties
This commit is contained in:
parent
107fa1fdb8
commit
d2710ad73f
2 changed files with 18 additions and 0 deletions
|
@ -487,6 +487,23 @@ ThrowCompletionOr<void> Object::copy_data_properties(VM& vm, Value source, HashT
|
|||
return {};
|
||||
}
|
||||
|
||||
// 14.7 SnapshotOwnProperties ( source, proto [ , excludedKeys [ , excludedValues ] ] ), https://tc39.es/proposal-temporal/#sec-snapshotownproperties
|
||||
ThrowCompletionOr<NonnullGCPtr<Object>> Object::snapshot_own_properties(VM& vm, GCPtr<Object> prototype, HashTable<PropertyKey> const& excluded_keys, HashTable<Value> const& excluded_values)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let copy be OrdinaryObjectCreate(proto).
|
||||
auto copy = Object::create(realm, prototype);
|
||||
|
||||
// 2. If excludedKeys is not present, set excludedKeys to « ».
|
||||
// 3. If excludedValues is not present, set excludedValues to « ».
|
||||
// 4. Perform ? CopyDataProperties(copy, source, excludedKeys, excludedValues).
|
||||
TRY(copy->copy_data_properties(vm, Value { this }, excluded_keys, excluded_values));
|
||||
|
||||
// 5. Return copy.
|
||||
return copy;
|
||||
}
|
||||
|
||||
// 7.3.27 PrivateElementFind ( O, P ), https://tc39.es/ecma262/#sec-privateelementfind
|
||||
PrivateElement* Object::private_element_find(PrivateName const& name)
|
||||
{
|
||||
|
|
|
@ -119,6 +119,7 @@ public:
|
|||
ThrowCompletionOr<bool> test_integrity_level(IntegrityLevel) const;
|
||||
ThrowCompletionOr<MarkedVector<Value>> enumerable_own_property_names(PropertyKind kind) const;
|
||||
ThrowCompletionOr<void> copy_data_properties(VM&, Value source, HashTable<PropertyKey> const& excluded_keys, HashTable<JS::Value> const& excluded_values = {});
|
||||
ThrowCompletionOr<NonnullGCPtr<Object>> snapshot_own_properties(VM&, GCPtr<Object> prototype, HashTable<PropertyKey> const& excluded_keys = {}, HashTable<Value> const& excluded_values = {});
|
||||
|
||||
PrivateElement* private_element_find(PrivateName const& name);
|
||||
ThrowCompletionOr<void> private_field_add(PrivateName const& name, Value value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue