refactor(core): rename ViewContainer to ViewContainerRef
This also renames InternalAppViewContainer into AppViewContainer Related to #1477 Closes #1554
This commit is contained in:
@ -8,7 +8,7 @@ import {Attribute, Query} from 'angular2/src/core/annotations/di';
|
||||
import {onDestroy} from 'angular2/src/core/annotations/annotations';
|
||||
import {Optional, Injector, Inject, bind} from 'angular2/di';
|
||||
import {AppProtoView, AppView} from 'angular2/src/core/compiler/view';
|
||||
import {ViewContainer} from 'angular2/src/core/compiler/view_container';
|
||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||
import {NgElement} from 'angular2/src/core/compiler/ng_element';
|
||||
import {Directive} from 'angular2/src/core/annotations/annotations';
|
||||
import {DynamicChangeDetector, ChangeDetectorRef, Parser, Lexer} from 'angular2/change_detection';
|
||||
@ -130,7 +130,7 @@ class NeedsElementRef {
|
||||
|
||||
class NeedsViewContainer {
|
||||
viewContainer;
|
||||
constructor(vc:ViewContainer) {
|
||||
constructor(vc:ViewContainerRef) {
|
||||
this.viewContainer = vc;
|
||||
}
|
||||
}
|
||||
@ -717,9 +717,9 @@ export function main() {
|
||||
expect(inj.get(NeedsChangeDetectorRef).changeDetectorRef).toBe(cd.ref);
|
||||
});
|
||||
|
||||
it('should inject ViewContainer', () => {
|
||||
it('should inject ViewContainerRef', () => {
|
||||
var inj = injector([NeedsViewContainer]);
|
||||
expect(inj.get(NeedsViewContainer).viewContainer).toBeAnInstanceOf(ViewContainer);
|
||||
expect(inj.get(NeedsViewContainer).viewContainer).toBeAnInstanceOf(ViewContainerRef);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -31,7 +31,7 @@ import {Attribute} from 'angular2/src/core/annotations/di';
|
||||
|
||||
import {If} from 'angular2/src/directives/if';
|
||||
|
||||
import {ViewContainer} from 'angular2/src/core/compiler/view_container';
|
||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||
import {Compiler} from 'angular2/src/core/compiler/compiler';
|
||||
import {ElementRef} from 'angular2/src/core/compiler/element_injector';
|
||||
|
||||
@ -690,7 +690,7 @@ export function main() {
|
||||
|
||||
describe('dynamic ViewContainers', () => {
|
||||
|
||||
it('should allow to create a ViewContainer at any bound location',
|
||||
it('should allow to create a ViewContainerRef at any bound location',
|
||||
inject([TestBed, AsyncTestCompleter, Compiler], (tb, async, compiler) => {
|
||||
tb.overrideView(MyComp, new View({
|
||||
template: '<div><dynamic-vp #dynamic></dynamic-vp></div>',
|
||||
@ -862,7 +862,7 @@ class SimpleImperativeViewComponent {
|
||||
})
|
||||
class DynamicViewport {
|
||||
done;
|
||||
constructor(vc:ViewContainer, inj:Injector, compiler:Compiler) {
|
||||
constructor(vc:ViewContainerRef, inj:Injector, compiler:Compiler) {
|
||||
var myService = new MyService();
|
||||
myService.greeting = 'dynamic greet';
|
||||
this.done = compiler.compileInHost(ChildCompUsingService).then( (hostPv) => {
|
||||
@ -1040,7 +1040,7 @@ class ChildComp2 {
|
||||
selector: '[some-viewport]'
|
||||
})
|
||||
class SomeViewport {
|
||||
constructor(container: ViewContainer) {
|
||||
constructor(container: ViewContainerRef) {
|
||||
container.create().setLocal('some-tmpl', 'hello');
|
||||
container.create().setLocal('some-tmpl', 'again');
|
||||
}
|
||||
|
@ -19,14 +19,14 @@ import {MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {IMPLEMENTS, isBlank, isPresent} from 'angular2/src/facade/lang';
|
||||
|
||||
import {ElementRef} from 'angular2/src/core/compiler/element_injector';
|
||||
import {AppView, AppProtoView, InternalAppViewContainer} from 'angular2/src/core/compiler/view';
|
||||
import {ViewContainer} from 'angular2/src/core/compiler/view_container';
|
||||
import {AppView, AppProtoView, AppViewContainer} from 'angular2/src/core/compiler/view';
|
||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||
import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
|
||||
|
||||
export function main() {
|
||||
// TODO(tbosch): add missing tests
|
||||
|
||||
describe('ViewContainer', () => {
|
||||
describe('ViewContainerRef', () => {
|
||||
var location;
|
||||
var view;
|
||||
var viewManager;
|
||||
@ -40,7 +40,7 @@ export function main() {
|
||||
}
|
||||
|
||||
function createViewContainer(defaultProtoView = null) {
|
||||
return new ViewContainer(viewManager, location, defaultProtoView);
|
||||
return new ViewContainerRef(viewManager, location, defaultProtoView);
|
||||
}
|
||||
|
||||
beforeEach( () => {
|
||||
@ -50,14 +50,14 @@ export function main() {
|
||||
location = new ElementRef(null, view, 0, null, null, null);
|
||||
});
|
||||
|
||||
it('should return a 0 length if there is no underlying ViewContainer', () => {
|
||||
it('should return a 0 length if there is no underlying ViewContainerRef', () => {
|
||||
var vc = createViewContainer();
|
||||
expect(vc.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should return the size of the underlying ViewContainer', () => {
|
||||
it('should return the size of the underlying ViewContainerRef', () => {
|
||||
var vc = createViewContainer();
|
||||
view.viewContainers = [new InternalAppViewContainer()];
|
||||
view.viewContainers = [new AppViewContainer()];
|
||||
view.viewContainers[0].views = [createView()];
|
||||
expect(vc.length).toBe(1);
|
||||
});
|
@ -18,8 +18,8 @@ import {Injector, bind} from 'angular2/di';
|
||||
import {IMPLEMENTS, isBlank, isPresent} from 'angular2/src/facade/lang';
|
||||
import {MapWrapper, ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {AppProtoView, AppView, InternalAppViewContainer} from 'angular2/src/core/compiler/view';
|
||||
import {Renderer, ViewRef, ProtoViewRef, ViewContainerRef} from 'angular2/src/render/api';
|
||||
import {AppProtoView, AppView, AppViewContainer} from 'angular2/src/core/compiler/view';
|
||||
import {Renderer, ViewRef, ProtoViewRef, RenderViewContainerRef} from 'angular2/src/render/api';
|
||||
import {ElementBinder} from 'angular2/src/core/compiler/element_binder';
|
||||
import {DirectiveBinding, ElementInjector, ElementRef} from 'angular2/src/core/compiler/element_injector';
|
||||
import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader';
|
||||
@ -122,7 +122,7 @@ export function main() {
|
||||
utils.spy('attachViewInContainer').andCallFake( (parentView, elementIndex, atIndex, childView) => {
|
||||
var viewContainer = parentView.viewContainers[elementIndex];
|
||||
if (isBlank(viewContainer)) {
|
||||
viewContainer = new InternalAppViewContainer();
|
||||
viewContainer = new AppViewContainer();
|
||||
parentView.viewContainers[elementIndex] = viewContainer;
|
||||
}
|
||||
ListWrapper.insert(viewContainer.views, atIndex, childView);
|
||||
@ -385,7 +385,7 @@ export function main() {
|
||||
childProtoView = createProtoView();
|
||||
});
|
||||
|
||||
it('should create a ViewContainer if not yet existing', () => {
|
||||
it('should create a ViewContainerRef if not yet existing', () => {
|
||||
manager.createViewInContainer(elementRef(parentView, 0), 0, childProtoView, null);
|
||||
expect(parentView.viewContainers[0]).toBeTruthy();
|
||||
});
|
||||
@ -411,7 +411,7 @@ export function main() {
|
||||
it('should create and set the render view', () => {
|
||||
manager.createViewInContainer(elementRef(parentView, 0), 0, childProtoView, null);
|
||||
expect(renderer.spy('createViewInContainer')).toHaveBeenCalledWith(
|
||||
new ViewContainerRef(parentView.render, 0), 0, childProtoView.render);
|
||||
new RenderViewContainerRef(parentView.render, 0), 0, childProtoView.render);
|
||||
expect(createdViews[0].render).toBe(createdRenderViews[0]);
|
||||
});
|
||||
|
||||
@ -451,7 +451,7 @@ export function main() {
|
||||
|
||||
it('should destroy and clear the render view', () => {
|
||||
manager.destroyViewInContainer(elementRef(parentView, 0), 0);
|
||||
expect(renderer.spy('destroyViewInContainer')).toHaveBeenCalledWith(new ViewContainerRef(parentView.render, 0), 0);
|
||||
expect(renderer.spy('destroyViewInContainer')).toHaveBeenCalledWith(new RenderViewContainerRef(parentView.render, 0), 0);
|
||||
expect(childView.render).toBe(null);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user