mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:37:35 +00:00
LibJS: Fast-path ToTemporalCalendar when the argument is a Calendar
This is a normative change in the Temporal spec.
See: 2a43b39
This commit is contained in:
parent
4b27c6e688
commit
8c3512d6ce
2 changed files with 29 additions and 4 deletions
|
@ -24,4 +24,22 @@ describe("normal behavior", () => {
|
|||
expect(Temporal.Calendar.from("iso8601").id).toBe("iso8601");
|
||||
expect(Temporal.Calendar.from("2021-07-06[u-ca=iso8601]").id).toBe("iso8601");
|
||||
});
|
||||
|
||||
test("ToTemporalCalendar fast path returns if it is passed a Temporal.Calendar instance", () => {
|
||||
// This is obseravble via there being no property lookups (avoiding a "calendar" property lookup in this case)
|
||||
let madeObservableHasPropertyLookup = false;
|
||||
class Calendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
|
||||
get calendar() {
|
||||
madeObservableHasPropertyLookup = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
const calendar = new Calendar();
|
||||
Temporal.Calendar.from(calendar);
|
||||
expect(madeObservableHasPropertyLookup).toBeFalse();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue