Skip to content

Commit 4e63f25

Browse files
ptomatoMs2ger
authored andcommitted
Normative: Ensure an Object is returned from calendar.mergeFields()
In each case where CalendarMergeFields is called, it is later asserted in PrepareTemporalFields that Type(_fields_) is Object. Previously the spec text failed this assertion. The tests check that a TypeError is thrown in this case, as well as that the TypeError is thrown before the value is passed to any dateFromFields() or similar method.
1 parent 4ec075f commit 4e63f25

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/ecmascript.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,9 @@ export const ES = ObjectAssign({}, ES2020, {
15341534
CalendarMergeFields: (calendar, fields, additionalFields) => {
15351535
const mergeFields = ES.GetMethod(calendar, 'mergeFields');
15361536
if (mergeFields === undefined) return { ...fields, ...additionalFields };
1537-
return ES.Call(mergeFields, calendar, [fields, additionalFields]);
1537+
const result = ES.Call(mergeFields, calendar, [fields, additionalFields]);
1538+
if (ES.Type(result) !== 'Object') throw new TypeError('bad return from calendar.mergeFields()');
1539+
return result;
15381540
},
15391541
CalendarDateAdd: (calendar, date, duration, options, dateAdd) => {
15401542
if (dateAdd === undefined) {

0 commit comments

Comments
 (0)