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

LibJS: Don't update names of resulting functions in object expression

The only cases where the name should be set is if the function comes
from a direct anonymous function expression.
This commit is contained in:
davidot 2022-12-13 01:30:32 +01:00 committed by Linus Groh
parent 897c7f7cc2
commit 2bbea62176
4 changed files with 63 additions and 10 deletions

View file

@ -3095,18 +3095,21 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
continue;
}
if (value.is_function() && property.is_method())
auto property_key = TRY(PropertyKey::from_value(vm, key));
if (property.is_method()) {
VERIFY(value.is_function());
static_cast<ECMAScriptFunctionObject&>(value.as_function()).set_home_object(object);
auto property_key = TRY(PropertyKey::from_value(vm, key));
auto name = TRY(get_function_property_name(property_key));
if (property.type() == ObjectProperty::Type::Getter) {
name = DeprecatedString::formatted("get {}", name);
} else if (property.type() == ObjectProperty::Type::Setter) {
name = DeprecatedString::formatted("set {}", name);
}
auto name = MUST(get_function_property_name(property_key));
if (property.type() == ObjectProperty::Type::Getter) {
name = DeprecatedString::formatted("get {}", name);
} else if (property.type() == ObjectProperty::Type::Setter) {
name = DeprecatedString::formatted("set {}", name);
}
update_function_name(value, name);
update_function_name(value, name);
}
switch (property.type()) {
case ObjectProperty::Type::Getter: