Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit 17ad3e9

Browse files
committed
Really don't override native Intl toLocaleString functions
Closes #61, really fixes #58
1 parent a2da64d commit 17ad3e9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Intl.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ var
4040
// We use this a lot (and need it for proto-less objects)
4141
hop = Object.prototype.hasOwnProperty,
4242

43-
// Does the browser already support Intl .toLocaleString() functions?
44-
tls = (1.23).toLocaleString(undefined, {style:'currency', currency: 'ZZZ'}).indexOf('ZZZ') > -1,
43+
// Determine whether we need to override ECMA-262 locale sensitive functions
44+
overrideTLS = (function () {
45+
try { (0).toLocaleString(null); return true; } catch (e) { return false; }
46+
})(),
4547

4648
// Naive defineProperty for compatibility
4749
defineProperty = realDefineProp ? Object.defineProperty : function (obj, name, desc) {
@@ -2628,7 +2630,7 @@ function ToLocalTime(date, calendar, timeZone) {
26282630
// Sect 13 Locale Sensitive Functions of the ECMAScript Language Specification
26292631
// ===========================================================================
26302632

2631-
if (tls) {
2633+
if (overrideTLS) {
26322634
/**
26332635
* When the toLocaleString method is called with optional arguments locales and options,
26342636
* the following steps are taken:

0 commit comments

Comments
 (0)