Skip to content

Commit 592b100

Browse files
committed
Additonal validation for hard-coded era data
This adds an additional check to make sure that the (hard-coded) era definitions for each calendar aren't missing required `isoEpoch` properties. Note that this code is only run once at load time, not each time calendars are accessed, so there's no runtime impact.
1 parent efe4498 commit 592b100

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

polyfill/lib/calendar.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@ function adjustEras(eras) {
13891389
ArraySort.call(eras, (e1, e2) => {
13901390
if (e1.reverseOf) return 1;
13911391
if (e2.reverseOf) return -1;
1392+
if (!e1.isoEpoch || !e2.isoEpoch) throw new RangeError('Invalid era data: missing ISO epoch');
13921393
return e2.isoEpoch.year - e1.isoEpoch.year;
13931394
});
13941395

0 commit comments

Comments
 (0)