FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(observable-array): splice to notify correct amount of added items… · NativeScript/NativeScript@f384d89 · GitHub

Commit f384d89

Browse files
authored andcommitted
fix(observable-array): splice to notify correct amount of added items (#7426)
1 parent aa5d861 commit f384d89

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎tests/app/data/observable-array-tests.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ export const test_ObservableArray_spliceShouldRemoveAndInertSpecifiedNumberOfEle
410410
// args.action is "splice".
411411
// args.index is the start index.
412412
// args.removed.length is equal to the number of deleted items.
413-
// args.addedCount is equal to the delta between number of inserted items and number of deleted items but not less than 0.
413+
// args.addedCount is equal to the amount of added and replaced items.
414414

415415
// >> (hide)
416416
result = args;
@@ -421,7 +421,7 @@ export const test_ObservableArray_spliceShouldRemoveAndInertSpecifiedNumberOfEle
421421
// << observable-array-splice-args-change
422422

423423
TKUnit.assert(result.eventName === ObservableArray.changeEvent && result.action === ChangeType.Splice &&
424-
result.removed.length === 2 && result.index === 1 && result.addedCount === 1, "ObservableArray splice() should raise 'change' event with correct args!");
424+
result.removed.length === 2 && result.index === 1 && result.addedCount === 3, "ObservableArray splice() should raise 'change' event with correct args!");
425425
};
426426

427427
export const test_ObservableArray_unshiftShouldInsertNewElementsFromTheStart = function () {

‎tns-core-modules/data/observable-array/observable-array.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export class ObservableArray<T> extends observable.Observable implements observa
207207
action: ChangeType.Splice,
208208
index: start,
209209
removed: result,
210-
addedCount: this._array.length > length ? this._array.length - length : 0
210+
addedCount: this._array.length + result.length - length
211211
});
212212
if (this._array.length !== length) {
213213
this._notifyLengthChange();

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL