소스 검색

Update replaceItems behavior. Bug fix.

Afshin Darian 8 년 전
부모
커밋
4eb0a39431
1개의 변경된 파일9개의 추가작업 그리고 6개의 파일을 삭제
  1. 9 6
      src/common/observablelist.ts

+ 9 - 6
src/common/observablelist.ts

@@ -623,12 +623,15 @@ class ObservableList<T> implements IObservableList<T> {
    * This may be reimplemented by subclasses to customize the behavior.
    */
   protected replaceItems(index: number, count: number, items: T[]): T[] {
-    let i = index;
-    let old = items.map(item => {
-      let removed = this.internal.at(i);
-      this.internal.set(i++, item);
-      return removed;
-    });
+    let old: T[] = [];
+    while (count-- > 0) {
+      old.push(this.internal.removeAt(index));
+    }
+
+    while (items.length) {
+      this.internal.insert(index++, items.shift());
+    }
+
     this.changed.emit({
       type: 'replace',
       newIndex: index,