Skip to content

Commit 897e56a

Browse files
committed
Spec-compliance fix in GetStringOrNumberOption
See: #1411
1 parent 828ed33 commit 897e56a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/ecmascript.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,12 @@ export const ES = ObjectAssign({}, ES2020, {
680680
default: // fall through if option not given
681681
}
682682
let digits = options.fractionalSecondDigits;
683-
if (digits === undefined || digits === 'auto') return { precision: 'auto', unit: 'nanosecond', increment: 1 };
684-
digits = ES.ToNumber(digits);
683+
if (digits === undefined) digits = 'auto';
684+
if (ES.Type(digits) !== 'Number') {
685+
digits = ES.ToString(digits);
686+
if (digits === 'auto') return { precision: 'auto', unit: 'nanosecond', increment: 1 };
687+
throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${digits}`);
688+
}
685689
if (NumberIsNaN(digits) || digits < 0 || digits > 9) {
686690
throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${digits}`);
687691
}

0 commit comments

Comments
 (0)