fix(filters): always call splice() with 2 arguments or more
When calling `.splice()` without a 2nd argument (`deleteCount`), most browsers will splice to the end of the array. As it turns out, this is the behavior specified in [ES2015][es6]. In [ES5][es5], the spec seems to imply that nothing should happen. To avoid inconsistent behavior among browsers implementing different versions of the EcmaScript standart or when ES5 shims are included (e.g. https://github.com/es-shims/es5-shim/), this commit ensures that all calls to `.splice()` provide at least two arguments. [es5]: http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.12 [es6]: http://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.splice Fixes #14467 Closes #14489
This commit is contained in:
@@ -317,7 +317,7 @@ function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
|
||||
|
||||
// extract decimals digits
|
||||
if (integerLen > 0) {
|
||||
decimals = digits.splice(integerLen);
|
||||
decimals = digits.splice(integerLen, digits.length);
|
||||
} else {
|
||||
decimals = digits;
|
||||
digits = [0];
|
||||
@@ -326,10 +326,10 @@ function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
|
||||
// format the integer digits with grouping separators
|
||||
var groups = [];
|
||||
if (digits.length >= pattern.lgSize) {
|
||||
groups.unshift(digits.splice(-pattern.lgSize).join(''));
|
||||
groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));
|
||||
}
|
||||
while (digits.length > pattern.gSize) {
|
||||
groups.unshift(digits.splice(-pattern.gSize).join(''));
|
||||
groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));
|
||||
}
|
||||
if (digits.length) {
|
||||
groups.unshift(digits.join(''));
|
||||
|
||||
Reference in New Issue
Block a user