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

Commit 6f1fae8

Browse files
committed
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
1 parent f964850 commit 6f1fae8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ng/filter/filters.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
317317

318318
// extract decimals digits
319319
if (integerLen > 0) {
320-
decimals = digits.splice(integerLen);
320+
decimals = digits.splice(integerLen, digits.length);
321321
} else {
322322
decimals = digits;
323323
digits = [0];
@@ -326,10 +326,10 @@ function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
326326
// format the integer digits with grouping separators
327327
var groups = [];
328328
if (digits.length >= pattern.lgSize) {
329-
groups.unshift(digits.splice(-pattern.lgSize).join(''));
329+
groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));
330330
}
331331
while (digits.length > pattern.gSize) {
332-
groups.unshift(digits.splice(-pattern.gSize).join(''));
332+
groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));
333333
}
334334
if (digits.length) {
335335
groups.unshift(digits.join(''));

0 commit comments

Comments
 (0)