Skip to content

Commit

Permalink
feat: upgrade Intl polyfills & add Chromium bug detection for Intl.Di…
Browse files Browse the repository at this point in the history
…splayNames
  • Loading branch information
longlho authored and JakeChampion committed Aug 15, 2020
1 parent 810bd14 commit d869a01
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 2,453 deletions.
63 changes: 32 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
},
"dependencies": {
"@financial-times/polyfill-useragent-normaliser": "^1.7.0",
"@formatjs/intl-datetimeformat": "^2.0.2",
"@formatjs/intl-displaynames": "^3.0.2",
"@formatjs/intl-getcanonicallocales": "^1.2.10",
"@formatjs/intl-listformat": "^3.0.2",
"@formatjs/intl-numberformat": "^5.0.2",
"@formatjs/intl-pluralrules": "^3.0.2",
"@formatjs/intl-relativetimeformat": "^6.0.2",
"@formatjs/intl-datetimeformat": "^2.4.0",
"@formatjs/intl-displaynames": "^3.1.7",
"@formatjs/intl-getcanonicallocales": "^1.3.1",
"@formatjs/intl-listformat": "^4.0.0",
"@formatjs/intl-numberformat": "^5.3.3",
"@formatjs/intl-pluralrules": "^3.2.5",
"@formatjs/intl-relativetimeformat": "^7.0.0",
"@juggle/resize-observer": "^3.2.0",
"@webcomponents/template": "^1.4.0",
"Base64": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion polyfills/Intl/DateTimeFormat/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ samsung_mob = "*"

[install]
module = "@formatjs/intl-datetimeformat"
paths = [ "dist/umd/polyfill.js" ]
paths = [ "polyfill.js" ]
postinstall = "update.task.js"
2 changes: 1 addition & 1 deletion polyfills/Intl/DisplayNames/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ samsung_mob = "*"

[install]
module = "@formatjs/intl-displaynames"
paths = [ "dist/umd/polyfill.js" ]
paths = [ "polyfill.js" ]
postinstall = "update.task.js"

12 changes: 11 additions & 1 deletion polyfills/Intl/DisplayNames/detect.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
'Intl' in self && 'DisplayNames' in self.Intl
'Intl' in self && 'DisplayNames' in self.Intl &&
/**
* https://bugs.chromium.org/p/chromium/issues/detail?id=1097432
*/
(function hasMissingICUBug() {
if (Intl.DisplayNames) {
const regionNames = new Intl.DisplayNames(['en'], {type: 'region'});
return regionNames.of('CA') === 'CA';
}
return false;
})()
15 changes: 11 additions & 4 deletions polyfills/Intl/DisplayNames/update.task.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ configSource.test = { ci: false };
var configFileSource = TOML.stringify(configSource);

function intlLocaleDetectFor(locale) {
return "'Intl' in self && " +
"Intl.DisplayNames && " +
"Intl.DisplayNames.supportedLocalesOf && " +
"Intl.DisplayNames.supportedLocalesOf('"+locale+"').length === 1";
return `'Intl' in self &&
Intl.DisplayNames &&
Intl.DisplayNames.supportedLocalesOf &&
Intl.DisplayNames.supportedLocalesOf('${locale}').length === 1 &&
(function hasMissingICUBug() {
if (Intl.DisplayNames) {
const regionNames = new Intl.DisplayNames(['en'], {type: 'region'});
return regionNames.of('CA') === 'CA';
}
return false;
})()`;
}

console.log('Importing Intl.DisplayNames~locale.* polyfill from ' + LocalesPath);
Expand Down
2 changes: 1 addition & 1 deletion polyfills/Intl/ListFormat/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ samsung_mob = "*"

[install]
module = "@formatjs/intl-listformat"
paths = [ "dist/umd/polyfill-intl-listformat.js" ]
paths = [ "polyfill.js" ]
postinstall = "update.task.js"

2 changes: 1 addition & 1 deletion polyfills/Intl/NumberFormat/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ samsung_mob = "*"

[install]
module = "@formatjs/intl-numberformat"
paths = [ "dist/umd/polyfill.js" ]
paths = [ "polyfill.js" ]
postinstall = "update.task.js"

2 changes: 1 addition & 1 deletion polyfills/Intl/PluralRules/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ samsung_mob = "*"

[install]
module = "@formatjs/intl-pluralrules"
paths = [ "dist/umd/polyfill.js" ]
paths = [ "polyfill.js" ]
postinstall = "update.task.js"
2 changes: 1 addition & 1 deletion polyfills/Intl/PluralRules/update.task.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function intlLocaleDetectFor(locale) {
return "'Intl' in this && " +
"Intl.PluralRules && " +
"Intl.PluralRules.supportedLocalesOf && " +
'(function() { try { return Intl.PluralRules.supportedLocalesOf("' + locale + '").length === 1; } catch (e) { return false; } }())';
'Intl.PluralRules.supportedLocalesOf("' + locale + '").length === 1';
}

console.log('Importing Intl.PluralRules~locale.* polyfill from ' + LocalesPath);
Expand Down
2 changes: 1 addition & 1 deletion polyfills/Intl/RelativeTimeFormat/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ samsung_mob = "<6"

[install]
module = "@formatjs/intl-relativetimeformat"
paths = [ "dist/umd/polyfill-intl-relativetimeformat.js" ]
paths = [ "polyfill.js" ]
postinstall = "update.task.js"

2 changes: 1 addition & 1 deletion polyfills/Intl/getCanonicalLocales/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ samsung_mob = "*"

[install]
module = "@formatjs/intl-getcanonicallocales"
paths = [ "dist/umd/polyfill.js" ]
paths = [ "polyfill.js" ]

0 comments on commit d869a01

Please sign in to comment.