Skip to content

Commit

Permalink
Editorial: Avoid hitting nonnull assertion for bestFormat
Browse files Browse the repository at this point in the history
In a94a793 the desired behaviour when formatting Temporal objects was
accidentally applied to formatting Date objects. So

new Date().toLocaleDateString([],  { hour: "numeric" });

would result in bestFormat being null, and according to the type assertion
of the Intl.DateTimeFormat [[DateTimeFormat]] internal slot, that is not
possible.

Checking that _inherit_ = ~relevant~ here ensures the new behaviour is
only applied to Temporal objects, and the type assertion is not hit.

See: #3049
  • Loading branch information
ptomato authored and Ms2ger committed Dec 6, 2024
1 parent 01c3845 commit 8a52801
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ <h1>
1. Set _formatOptions_.[[&lt;_prop_>]] to _value_.
1. Set _needDefaults_ to *false*.
1. If _needDefaults_ is *true*, then
1. If _anyPresent_ is *true*, return *null*.
1. If _anyPresent_ is *true* and _inherit_ is ~relevant~, return *null*.
1. For each property name _prop_ of _defaultOptions_, do
1. Set _formatOptions_.[[&lt;_prop_>]] to *"numeric"*.
1. If _defaults_ is ~zoned-date-time~, then
Expand Down

0 comments on commit 8a52801

Please sign in to comment.