@js-temporal/polyfill
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -0,1 +1,11 @@ | ||
# 0.4.1 | ||
This version is a patch version enabling polyfill compatibilit with Safari | ||
versions <15.1 (October 2021 and earlier). | ||
Bug fixes: | ||
- Remove erroneous options from Safari's Intl.DateTimeFormat resolvedOptions | ||
bag. The underlying bug in Safari was fixed in Safari 15.1. | ||
# 0.4.0 | ||
@@ -2,0 +12,0 @@ |
@@ -211,7 +211,27 @@ import * as ES from './ecmascript'; | ||
if (options.timeZone === timeZone) return formatter; | ||
// Existing Intl isn't typed to accept Temporal-specific options, but will not | ||
// break at runtime if we pass them. Also, the lib types for resolved options | ||
// are less restrictive than the types for options. For example, `weekday` is | ||
// Existing Intl isn't typed to accept Temporal-specific options and the lib | ||
// types for resolved options are less restrictive than the types for options. | ||
// For example, `weekday` is | ||
// `'long' | 'short' | 'narrow'` in options but `string` in resolved options. | ||
// TODO: investigate why, and file an issue against TS if it's a bug. | ||
if ((options as any)['dateStyle'] || (options as any)['timeStyle']) { | ||
// Unfortunately, Safari's resolvedOptions include parameters that will | ||
// cause errors at runtime if passed along with | ||
// dateStyle or timeStyle options as per | ||
// https://tc39.es/proposal-intl-datetime-style/#table-datetimeformat-components. | ||
// This has been fixed in newer versions of Safari: | ||
// https://bugs.webkit.org/show_bug.cgi?id=231041 | ||
delete options['weekday']; | ||
delete options['era']; | ||
delete options['year']; | ||
delete options['month']; | ||
delete options['day']; | ||
delete options['hour']; | ||
delete options['minute']; | ||
delete options['second']; | ||
delete options['timeZoneName']; | ||
delete (options as any)['hourCycle']; | ||
delete options['hour12']; | ||
delete (options as any)['dayPeriod']; | ||
} | ||
return new IntlDateTimeFormat(options.locale, { ...(options as globalThis.Intl.DateTimeFormatOptions), timeZone }); | ||
@@ -218,0 +238,0 @@ } |
{ | ||
"name": "@js-temporal/polyfill", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Polyfill for Tc39 Stage 3 proposal Temporal (https://github.com/tc39/proposal-temporal)", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
5073993
46272