refactor: remove some facades (#12335)

This commit is contained in:
Victor Berchet
2016-10-19 13:42:39 -07:00
committed by Alex Rickabaugh
parent 0ecd9b2df0
commit 76dd026447
58 changed files with 281 additions and 429 deletions

View File

@ -7,7 +7,7 @@
*/
import {isListLikeIterable, iterateListLike} from '../../facade/collection';
import {getMapKey, isArray, isBlank, isPresent, looseIdentical, stringify} from '../../facade/lang';
import {isBlank, looseIdentical, stringify} from '../../facade/lang';
import {ChangeDetectorRef} from '../change_detector_ref';
import {IterableDiffer, IterableDifferFactory, TrackByFn} from './iterable_differs';
@ -168,13 +168,13 @@ export class DefaultIterableDiffer implements IterableDiffer {
var record: CollectionChangeRecord = this._itHead;
var mayBeDirty: boolean = false;
var index: number;
var item: any /** TODO #9100 */;
var itemTrackBy: any /** TODO #9100 */;
if (isArray(collection)) {
var list = collection;
var item: any;
var itemTrackBy: any;
if (Array.isArray(collection)) {
const list = collection;
this._length = collection.length;
for (index = 0; index < this._length; index++) {
for (let index = 0; index < this._length; index++) {
item = list[index];
itemTrackBy = this._trackByFn(index, item);
if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
@ -700,11 +700,10 @@ class _DuplicateMap {
map = new Map<any, _DuplicateItemRecordList>();
put(record: CollectionChangeRecord) {
// todo(vicb) handle corner cases
var key = getMapKey(record.trackById);
const key = record.trackById;
var duplicates = this.map.get(key);
if (!isPresent(duplicates)) {
let duplicates = this.map.get(key);
if (!duplicates) {
duplicates = new _DuplicateItemRecordList();
this.map.set(key, duplicates);
}
@ -719,9 +718,8 @@ class _DuplicateMap {
* have any more `a`s needs to return the last `a` not the first or second.
*/
get(trackById: any, afterIndex: number = null): CollectionChangeRecord {
var key = getMapKey(trackById);
var recordList = this.map.get(key);
const key = trackById;
const recordList = this.map.get(key);
return recordList ? recordList.get(trackById, afterIndex) : null;
}
@ -731,10 +729,8 @@ class _DuplicateMap {
* The list of duplicates also is removed from the map if it gets empty.
*/
remove(record: CollectionChangeRecord): CollectionChangeRecord {
var key = getMapKey(record.trackById);
// todo(vicb)
// assert(this.map.containsKey(key));
var recordList: _DuplicateItemRecordList = this.map.get(key);
const key = record.trackById;
const recordList: _DuplicateItemRecordList = this.map.get(key);
// Remove the list of duplicates when it gets empty
if (recordList.remove(record)) {
this.map.delete(key);