mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
LibJS/Bytecode: Use CopyDataProperties AO for destructuring
The previous ad-hoc implementation ignored the non-enumerable flag.
This commit is contained in:
parent
afb07281ad
commit
c6c20d3bf3
1 changed files with 2 additions and 10 deletions
|
@ -356,7 +356,7 @@ ThrowCompletionOr<void> CopyObjectExcludingProperties::execute_impl(Bytecode::In
|
||||||
auto& vm = interpreter.vm();
|
auto& vm = interpreter.vm();
|
||||||
auto& realm = *vm.current_realm();
|
auto& realm = *vm.current_realm();
|
||||||
|
|
||||||
auto from_object = TRY(interpreter.reg(m_from_object).to_object(vm));
|
auto from_object = interpreter.reg(m_from_object);
|
||||||
|
|
||||||
auto to_object = Object::create(realm, realm.intrinsics().object_prototype());
|
auto to_object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||||
|
|
||||||
|
@ -365,15 +365,7 @@ ThrowCompletionOr<void> CopyObjectExcludingProperties::execute_impl(Bytecode::In
|
||||||
excluded_names.set(TRY(interpreter.reg(m_excluded_names[i]).to_property_key(vm)));
|
excluded_names.set(TRY(interpreter.reg(m_excluded_names[i]).to_property_key(vm)));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto own_keys = TRY(from_object->internal_own_property_keys());
|
TRY(to_object->copy_data_properties(vm, from_object, excluded_names));
|
||||||
|
|
||||||
for (auto& key : own_keys) {
|
|
||||||
auto property_key = TRY(key.to_property_key(vm));
|
|
||||||
if (!excluded_names.contains(property_key)) {
|
|
||||||
auto property_value = TRY(from_object->get(property_key));
|
|
||||||
to_object->define_direct_property(property_key, property_value, JS::default_attributes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interpreter.accumulator() = to_object;
|
interpreter.accumulator() = to_object;
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue