mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +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:
parent
897c7f7cc2
commit
2bbea62176
4 changed files with 63 additions and 10 deletions
|
@ -67,3 +67,11 @@ describe("normal behavior", () => {
|
|||
expect(o.foo).toBe("bar");
|
||||
});
|
||||
});
|
||||
|
||||
test("does not override frozen function name", () => {
|
||||
const func = Object.freeze(function () {
|
||||
return 12;
|
||||
});
|
||||
const obj = Object.freeze({ name: func });
|
||||
expect(obj.name()).toBe(12);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue