refactor: remove most facades (#12399)

This commit is contained in:
Victor Berchet
2016-10-21 15:14:44 -07:00
committed by Igor Minar
parent e319cfefc3
commit 57051f01ce
47 changed files with 204 additions and 444 deletions

View File

@ -7,7 +7,6 @@
*/
import {Injector} from '../di/injector';
import {ListWrapper} from '../facade/collection';
import {isPresent} from '../facade/lang';
import {ElementRef} from './element_ref';
@ -69,8 +68,8 @@ export class AppElement {
nestedViews = [];
this.nestedViews = nestedViews;
}
ListWrapper.removeAt(nestedViews, previousIndex);
ListWrapper.insert(nestedViews, currentIndex, view);
nestedViews.splice(previousIndex, 1);
nestedViews.splice(currentIndex, 0, view);
var refRenderNode: any /** TODO #9100 */;
if (currentIndex > 0) {
var prevView = nestedViews[currentIndex - 1];
@ -93,7 +92,7 @@ export class AppElement {
nestedViews = [];
this.nestedViews = nestedViews;
}
ListWrapper.insert(nestedViews, viewIndex, view);
nestedViews.splice(viewIndex, 0, view);
var refRenderNode: any /** TODO #9100 */;
if (viewIndex > 0) {
var prevView = nestedViews[viewIndex - 1];
@ -108,7 +107,7 @@ export class AppElement {
}
detachView(viewIndex: number): AppView<any> {
var view = ListWrapper.removeAt(this.nestedViews, viewIndex);
const view = this.nestedViews.splice(viewIndex, 1)[0];
if (view.type === ViewType.COMPONENT) {
throw new Error(`Component views can't be moved!`);
}

View File

@ -7,7 +7,6 @@
*/
import {Injector} from '../di/injector';
import {ListWrapper} from '../facade/collection';
import {unimplemented} from '../facade/errors';
import {isPresent} from '../facade/lang';
import {WtfScopeFn, wtfCreateScope, wtfLeave} from '../profile/profile';
@ -186,7 +185,7 @@ export class ViewContainerRef_ implements ViewContainerRef {
}
indexOf(viewRef: ViewRef): number {
return ListWrapper.indexOf(this._element.nestedViews, (<ViewRef_<any>>viewRef).internalView);
return this._element.nestedViews.indexOf((<ViewRef_<any>>viewRef).internalView);
}
/** @internal */
@ -194,9 +193,9 @@ export class ViewContainerRef_ implements ViewContainerRef {
// TODO(i): rename to destroy
remove(index: number = -1): void {
var s = this._removeScope();
const s = this._removeScope();
if (index == -1) index = this.length - 1;
var view = this._element.detachView(index);
const view = this._element.detachView(index);
view.destroy();
// view is intentionally not returned to the client.
wtfLeave(s);
@ -207,14 +206,14 @@ export class ViewContainerRef_ implements ViewContainerRef {
// TODO(i): refactor insert+remove into move
detach(index: number = -1): ViewRef {
var s = this._detachScope();
const s = this._detachScope();
if (index == -1) index = this.length - 1;
var view = this._element.detachView(index);
const view = this._element.detachView(index);
return wtfLeave(s, view.ref);
}
clear() {
for (var i = this.length - 1; i >= 0; i--) {
for (let i = this.length - 1; i >= 0; i--) {
this.remove(i);
}
}