Skip to content
52 changes: 49 additions & 3 deletions src/lib/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ function getFHPaddingEntries(index)
var LOCALE_INFINITY = Feature.LOCALE_INFINITY;
var LOCALE_NUMERALS_BN = Feature.LOCALE_NUMERALS_BN;
var LOCALE_NUMERALS_EXT = Feature.LOCALE_NUMERALS_EXT;
var LOCALE_NUMERALS_IE11_WIN7 = Feature.LOCALE_NUMERALS_IE11_WIN7;
var LOCALE_NUMERALS_IE11_WIN7_8 = Feature.LOCALE_NUMERALS_IE11_WIN7_8;
var LOCALE_NUMERALS_IE11_WIN8 = Feature.LOCALE_NUMERALS_IE11_WIN8;
var NAME = Feature.NAME;
var NO_FF_SRC = Feature.NO_FF_SRC;
var NO_IE_SRC = Feature.NO_IE_SRC;
Expand Down Expand Up @@ -466,10 +469,12 @@ function getFHPaddingEntries(index)
var expr = '(' + number + ')[TO_LOCALE_STRING](' + locale + ')';
if (index != null)
{
if (index > 4)
if (index % 10 === 8)
expr = '(' + R_PADDINGS[3] + ' + ' + expr + ')[' + (index - index % 10 + 11) + ']';
else if (index % 10 > 4)
{
var paddingBlock = R_PADDINGS[10 - index];
expr = '(' + paddingBlock + ' + ' + expr + ')[10]';
var paddingBlock = R_PADDINGS[10 - index % 10];
expr = '(' + paddingBlock + ' + ' + expr + ')[' + (index - index % 10 + 10) + ']';
}
else
expr += '[' + index + ']';
Expand Down Expand Up @@ -1076,6 +1081,8 @@ function getFHPaddingEntries(index)
define('Infinity[TO_LOCALE_STRING]("ja")[SLICE_OR_SUBSTR]("-1")'),
define('Infinity[TO_LOCALE_STRING]("ja").at("-1")', AT),
define('Infinity[TO_LOCALE_STRING]()', LOCALE_INFINITY),
define('Infinity[TO_LOCALE_STRING]("ja")[1]', LOCALE_NUMERALS_IE11_WIN7_8),
define('Infinity[TO_LOCALE_STRING]("ru")', LOCALE_NUMERALS_IE11_WIN8),
defineCharDefault(),
],
}); // eslint-disable-line @origin-1/bracket-layout
Expand Down Expand Up @@ -1669,21 +1676,60 @@ function getFHPaddingEntries(index)
useLocaleNumeralDefinition('ي', '"ar"', NaN, 1);
useLocaleNumeralDefinition('س', '"ar"', NaN, 2);
useLocaleNumeralDefinition('ر', '"ar"', NaN, 4, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('ب', '"ar"', NaN, 4, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ق', '"ar"', NaN, 5, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('ر', '"ar"', NaN, 5, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('م', '"ar"', NaN, 6, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('ق', '"ar"', NaN, 6, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('م', '"ar"', NaN, 7, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ا', '"ar"', Infinity, 2, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ن', '"ar"', Infinity, 4, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ه', '"ar"', Infinity, 5, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ة', '"ar"', Infinity, 8, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDigitDefinitions('"bn"', 0x09e6, LOCALE_NUMERALS_BN);
useLocaleNumeralDefinition('č', '"cs"', NaN, 5, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('μ', '"el"', NaN, 0, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('η', '"el"', NaN, 1, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('α', '"el"', NaN, 3, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ρ', '"el"', NaN, 4, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ι', '"el"', NaN, 5, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('θ', '"el"', NaN, 6, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ό', '"el"', NaN, 8, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ς', '"el"', NaN, 9, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('Ά', '"el"', Infinity, 0, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('π', '"el"', Infinity, 1, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ε', '"el"', Infinity, 2, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ο', '"el"', Infinity, 5, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDigitDefinitions('"fa"', 0x06f0);
useLocaleNumeralDefinition('٬', '"fa"', 1000, 1);
useLocaleNumeralDefinition('ن', '"fa"', NaN, 0, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('ا', '"fa"', NaN, 1, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('ع', '"fa"', NaN, 2, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('د', '"fa"', NaN, 3, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('ל', '"he"', NaN, 0, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('非', '"ja"', NaN, 5, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('数', '"ja"', NaN, 6, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('値', '"ja"', NaN, 7, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ė', '"lt"', Infinity, 7, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('ī', '"lv"', Infinity, 6, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('ś', '"pl"', Infinity, 13, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('н', '"ru"', NaN, 0, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('е', '"ru"', NaN, 1, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('ч', '"ru"', NaN, 3, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('и', '"ru"', NaN, 4, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('с', '"ru"', NaN, 5, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('л', '"ru"', NaN, 6, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('о', '"ru"', NaN, 7, LOCALE_NUMERALS_EXT);
useLocaleNumeralDefinition('б', '"ru"', Infinity, 0, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('е', '"ru"', Infinity, 1, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('с', '"ru"', Infinity, 2, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('к', '"ru"', Infinity, 3, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('н', '"ru"', Infinity, 5, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('ч', '"ru"', Infinity, 7, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('о', '"ru"', Infinity, 9, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('т', '"ru"', Infinity, 11, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('ь', '"ru"', Infinity, 12, LOCALE_NUMERALS_IE11_WIN7);
useLocaleNumeralDefinition('正', '"zh"', Infinity, 0, LOCALE_NUMERALS_IE11_WIN7_8);
useLocaleNumeralDefinition('字', '"zh-cn"', NaN, 2, LOCALE_NUMERALS_IE11_WIN7_8);
}
)();
82 changes: 78 additions & 4 deletions src/lib/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,69 @@ var featureInfos =
return available;
},
},
LOCALE_NUMERALS_IE11_WIN7:
{
description:
'Localized number formatting exclusive to Interner Explorer 11 in Windows 7.\n' +
'This includes Latvian string representation of Infinity ("bezgalība") and Russian ' +
'string representation of Infinity ("бесконечность").',
check:
function ()
{
var available =
checkLocaleNumeral('lv', Infinity, /^bezgalība/) &&
checkLocaleNumeral('ru', Infinity, /^бесконечность/);
return available;
},
},
LOCALE_NUMERALS_IE11_WIN7_8:
{
description:
'Localized number formatting exclusive to Interner Explorer 11 in Windows 7 and 8.\n' +
'This includes all features of LOCALE_NUMERALS plus the output of the letters in the ' +
'second word of the Arabic string representation of NaN ("برقم"), the letters in the ' +
'Arabic string representation of Infinity ("+لا\xa0نهاية"), the letters in the the Czech ' +
'string representation of NaN ("Není\xa0číslo"), the letters in the the Greek string ' +
'representation of Infinity ("Άπειρο"), the letters in the Greek string representation ' +
'of NaN ("μη\xa0αριθμός"), the letters in the Hebrew string representation of NaN ' +
'("לא\xa0מספר"), the characters in the Japanese string representation of Infinity ' +
'("+∞"), the characters in the Japanese string representation of NaN ("NaN\xa0(非数値)"), ' +
'the letters in the Lithuanian string representation of Infinity ("begalybė"), the ' +
'letters in the Polish string representation of Infinity ("+nieskończoność"), the ' +
'characters in the Chinese string representation of Infinity ("正无穷大" or "正無窮大"), the ' +
'characters in the Simplified Chinese string representation of NaN ("非数字").',
check:
function ()
{
var available =
checkLocaleNumeral('ar', NaN, /^ليس.برقم/) &&
checkLocaleNumeral('ar', Infinity, /^\+لا.نهاية/) &&
checkLocaleNumeral('cs', NaN, /^Není.číslo/) &&
checkLocaleNumeral('el', Infinity, /^Άπειρο/) &&
checkLocaleNumeral('el', NaN, /^μη.αριθμός/) &&
checkLocaleNumeral('he', NaN, /^לא.מספר/) &&
checkLocaleNumeral('ja', Infinity, /^\+∞/) &&
checkLocaleNumeral('ja', NaN, /^NaN.\(非数値\)/) &&
checkLocaleNumeral('lt', Infinity, /^begalybė/) &&
checkLocaleNumeral('pl', Infinity, /^\+nieskończoność/) &&
checkLocaleNumeral('zh', Infinity, /^正/) &&
checkLocaleNumeral('zh-cn', NaN, /^非数字/);
return available;
},
},
LOCALE_NUMERALS_IE11_WIN8:
{
description:
'Localized number formatting exclusive to Interner Explorer 11 in Windows 8.\n' +
'In this case, Latvian and Russian string representation of Infinity are both "∞".',
check:
function ()
{
var available = Infinity.toLocaleString('lv') === '∞' &&
Infinity.toLocaleString('ru') === '∞';
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Latvian is not used in definitions with this feature, it's fine to leave it out. We could mention only Russian.

Another thing I noticed is that this feature is supported in all modern browsers, so the name and the description don't seem to fit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just repurposed that into RUSSIAN_INFINITY for modern browsers usage.

return available;
},
},
NAME:
{
description: 'Existence of the name property for functions.',
Expand Down Expand Up @@ -645,17 +708,28 @@ var featureInfos =
],
attributes: { 'char-increment-restriction': null, 'web-worker-restriction': null },
},
IE_11_WIN_10:
IE_11_WIN_8:
{
inherits: 'IE_11',
versions: ['11'],
compatibilityTag: 'on Windows 8',
compatibilityShortTag: 'W8',
includes:
{ LOCALE_NUMERALS_IE11_WIN7: false, LOCALE_NUMERALS_IE11_WIN8: true },
},
IE_11_WIN_10:
{
inherits: 'IE_11_WIN_8',
versions: ['11'],
compatibilityTag: 'on Windows 10',
compatibilityShortTag: 'W10',
includes:
{
LOCALE_INFINITY: true,
LOCALE_NUMERALS_BN: true,
LOCALE_NUMERALS_EXT: true,
LOCALE_INFINITY: true,
LOCALE_NUMERALS_BN: true,
LOCALE_NUMERALS_EXT: true,
LOCALE_NUMERALS_IE11_WIN7_8: false,
LOCALE_NUMERALS_IE11_WIN8: false,
},
},
NODE_20:
Expand Down
151 changes: 151 additions & 0 deletions test/helpers/feature-emulation.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,157 @@
}
);
},
LOCALE_NUMERALS_IE11_WIN7:
function ()
{
registerNumberToLocaleStringAdapter
(
this,
function (locale)
{
switch (locale)
{
case 'lv':
switch (+this) // In Internet Explorer 9, +this is different from this.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internet Explorer 9 is no longer supported, so it's fine to use just this instead of +this.

Suggested change
switch (+this) // In Internet Explorer 9, +this is different from this.
switch (this)

Same for the other occurrences in this file.

{
case Infinity:
return 'bezgalība';
case -Infinity:
return '-bezgalība';
}
break;
case 'ru':
switch (+this) // In Internet Explorer 9, +this is different from this.
{
case Infinity:
return 'бесконечность';
case -Infinity:
return '-бесконечность';
}
break;
}
}
);
},
LOCALE_NUMERALS_IE11_WIN7_8:
function ()
{
registerNumberToLocaleStringAdapter
(
this,
function (locale)
{
var returnValue;
var number;
number = Number(this);
switch (locale)
{
case 'ar':
if (isNaN(number))
returnValue = 'ليس\xa0برقم';
else if (+this === Infinity)
returnValue = '+لا\xa0نهاية';
else if (+this === -Infinity)
returnValue = '-لا\xa0نهاية';
break;
case 'cs':
if (isNaN(number))
returnValue = 'Není\xa0číslo';
break;
case 'el':
if (isNaN(number))
returnValue = 'μη\xa0αριθμός';
else if (+this === Infinity)
returnValue = 'Άπειρο';
else if (+this === -Infinity)
returnValue = '-Άπειρο';
break;
case 'he':
if (isNaN(number))
returnValue = 'לא\xa0מספר';
break;
case 'ja':
if (isNaN(number))
returnValue = 'NaN\xa0(非数値)';
else if (+this === Infinity)
returnValue = '+∞';
else if (+this === -Infinity)
returnValue = '-∞';
break;
case 'lt':
switch (+this) // In Internet Explorer 9, +this is different from this.
{
case Infinity:
returnValue = 'begalybė';
break;
case -Infinity:
returnValue = '-begalybė';
break;
}
break;
case 'pl':
switch (+this) // In Internet Explorer 9, +this is different from this.
{
case Infinity:
returnValue = '+nieskończoność';
break;
case -Infinity:
returnValue = '-nieskończoność';
break;
}
break;
case 'zh':
switch (+this) // In Internet Explorer 9, +this is different from this.
{
case Infinity:
returnValue = '正无穷大';
break;
case -Infinity:
returnValue = '负无穷大';
break;
}
break;
case 'zh-cn':
if (isNaN(number))
returnValue = '非数字';
break;
}
return returnValue;
}
);
},
LOCALE_NUMERALS_IE11_WIN8:
function ()
{
registerNumberToLocaleStringAdapter
(
this,
function (locale)
{
switch (locale)
{
case 'lv':
switch (+this) // In Internet Explorer 9, +this is different from this.
{
case Infinity:
return '∞';
case -Infinity:
return '-∞';
}
break;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, this isn't needed

Suggested change
case 'lv':
switch (+this) // In Internet Explorer 9, +this is different from this.
{
case Infinity:
return '∞';
case -Infinity:
return '-∞';
}
break;

case 'ru':
switch (+this) // In Internet Explorer 9, +this is different from this.
{
case Infinity:
return '∞';
case -Infinity:
return '-∞';
}
break;
}
}
);
},
NAME:
function ()
{
Expand Down