chore(rename): rename View and Template concepts for #1244

This commit is contained in:
Pawel Kozlowski
2015-04-09 21:20:11 +02:00
committed by Jeremy Elbourn
parent 564477b8a0
commit bf7933714a
103 changed files with 767 additions and 765 deletions
+7 -7
View File
@@ -17,12 +17,12 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
import {ListWrapper} from 'angular2/src/facade/collection';
import {PromiseWrapper} from 'angular2/src/facade/async';
import {bind, Inject} from 'angular2/di';
import {Template} from 'angular2/src/core/annotations/template';
import {View} from 'angular2/src/core/annotations/view';
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
@Component({selector: 'hello-app'})
@Template({inline: '{{greeting}} world!'})
@View({template: '{{greeting}} world!'})
class HelloRootCmp {
greeting:string;
constructor() {
@@ -31,13 +31,13 @@ class HelloRootCmp {
}
@Component({selector: 'hello-app'})
@Template({inline: 'before: <content></content> after: done'})
@View({template: 'before: <content></content> after: done'})
class HelloRootCmpContent {
constructor() { }
}
@Component({selector: 'hello-app-2'})
@Template({inline: '{{greeting}} world, again!'})
@View({template: '{{greeting}} world, again!'})
class HelloRootCmp2 {
greeting:string;
constructor() {
@@ -46,7 +46,7 @@ class HelloRootCmp2 {
}
@Component({selector: 'hello-app'})
@Template({inline: ''})
@View({template: ''})
class HelloRootCmp3 {
appBinding;
@@ -56,7 +56,7 @@ class HelloRootCmp3 {
}
@Component({selector: 'hello-app'})
@Template({inline: ''})
@View({template: ''})
class HelloRootCmp4 {
lc;
@@ -87,7 +87,7 @@ export function main() {
});
describe('bootstrap factory method', () => {
it('should throw if no Template found', inject([AsyncTestCompleter], (async) => {
it('should throw if no View found', inject([AsyncTestCompleter], (async) => {
var injectorPromise = bootstrap(HelloRootMissingTemplate, testBindings, (e,t) => {throw e;});
PromiseWrapper.then(injectorPromise, null, (reason) => {
expect(reason.message).toContain('No template found for HelloRootMissingTemplate');
+41 -41
View File
@@ -17,12 +17,12 @@ import {Type, isBlank, stringify, isPresent} from 'angular2/src/facade/lang';
import {PromiseWrapper, Promise} from 'angular2/src/facade/async';
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
import {ProtoView} from 'angular2/src/core/compiler/view';
import {AppProtoView} from 'angular2/src/core/compiler/view';
import {ElementBinder} from 'angular2/src/core/compiler/element_binder';
import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader';
import {Component, DynamicComponent, Viewport, Decorator} from 'angular2/src/core/annotations/annotations';
import {PropertySetter, Attribute} from 'angular2/src/core/annotations/di';
import {Template} from 'angular2/src/core/annotations/template';
import {View} from 'angular2/src/core/annotations/view';
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver';
import {ComponentUrlMapper, RuntimeComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mapper';
@@ -41,7 +41,7 @@ export function main() {
cmpUrlMapper = new RuntimeComponentUrlMapper();
});
function createCompiler(renderCompileResults:List, protoViewFactoryResults:List<ProtoView>) {
function createCompiler(renderCompileResults:List, protoViewFactoryResults:List<AppProtoView>) {
var urlResolver = new FakeUrlResolver();
renderer = new FakeRenderer(renderCompileResults);
protoViewFactory = new FakeProtoViewFactory(protoViewFactoryResults)
@@ -58,8 +58,8 @@ export function main() {
describe('serialize template', () => {
function captureTemplate(template:Template):Promise<renderApi.Template> {
tplResolver.setTemplate(MainComponent, template);
function captureTemplate(template:View):Promise<renderApi.ViewDefinition> {
tplResolver.setView(MainComponent, template);
var compiler = createCompiler([createRenderProtoView()], [createProtoView()]);
return compiler.compile(MainComponent).then( (protoView) => {
expect(renderer.requests.length).toBe(1);
@@ -68,29 +68,29 @@ export function main() {
}
function captureDirective(directive):Promise<renderApi.DirectiveMetadata> {
return captureTemplate(new Template({inline: '<div></div>', directives: [directive]})).then( (renderTpl) => {
return captureTemplate(new View({template: '<div></div>', directives: [directive]})).then( (renderTpl) => {
expect(renderTpl.directives.length).toBe(1);
return renderTpl.directives[0];
});
}
it('should fill the componentId', inject([AsyncTestCompleter], (async) => {
captureTemplate(new Template({inline: '<div></div>'})).then( (renderTpl) => {
captureTemplate(new View({template: '<div></div>'})).then( (renderTpl) => {
expect(renderTpl.componentId).toEqual(stringify(MainComponent));
async.done();
});
}));
it('should fill inline', inject([AsyncTestCompleter], (async) => {
captureTemplate(new Template({inline: '<div></div>'})).then( (renderTpl) => {
expect(renderTpl.inline).toEqual('<div></div>');
it('should fill inline template', inject([AsyncTestCompleter], (async) => {
captureTemplate(new View({template: '<div></div>'})).then( (renderTpl) => {
expect(renderTpl.template).toEqual('<div></div>');
async.done();
});
}));
it('should fill absUrl given inline templates', inject([AsyncTestCompleter], (async) => {
cmpUrlMapper.setComponentUrl(MainComponent, '/mainComponent');
captureTemplate(new Template({inline: '<div></div>'})).then( (renderTpl) => {
captureTemplate(new View({template: '<div></div>'})).then( (renderTpl) => {
expect(renderTpl.absUrl).toEqual('http://www.app.com/mainComponent');
async.done();
});
@@ -98,7 +98,7 @@ export function main() {
it('should fill absUrl given url template', inject([AsyncTestCompleter], (async) => {
cmpUrlMapper.setComponentUrl(MainComponent, '/mainComponent');
captureTemplate(new Template({url: '/someTemplate'})).then( (renderTpl) => {
captureTemplate(new View({templateUrl: '/someTemplate'})).then( (renderTpl) => {
expect(renderTpl.absUrl).toEqual('http://www.app.com/mainComponent/someTemplate');
async.done();
});
@@ -167,9 +167,9 @@ export function main() {
});
}));
it('should set directive.events', inject([AsyncTestCompleter], (async) => {
it('should set directive.hostListeners', inject([AsyncTestCompleter], (async) => {
captureDirective(DirectiveWithEvents).then( (renderDir) => {
expect(renderDir.events).toEqual(MapWrapper.createFromStringMap({
expect(renderDir.hostListeners).toEqual(MapWrapper.createFromStringMap({
'someEvent': 'someAction'
}));
async.done();
@@ -178,7 +178,7 @@ export function main() {
it('should set directive.bind', inject([AsyncTestCompleter], (async) => {
captureDirective(DirectiveWithBind).then( (renderDir) => {
expect(renderDir.bind).toEqual(MapWrapper.createFromStringMap({
expect(renderDir.properties).toEqual(MapWrapper.createFromStringMap({
'a': 'b'
}));
async.done();
@@ -203,7 +203,7 @@ export function main() {
describe('call ProtoViewFactory', () => {
it('should pass the render protoView', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent, new Template({inline: '<div></div>'}));
tplResolver.setView(MainComponent, new View({template: '<div></div>'}));
var renderProtoView = createRenderProtoView();
var expectedProtoView = createProtoView();
var compiler = createCompiler([renderProtoView], [expectedProtoView]);
@@ -215,7 +215,7 @@ export function main() {
}));
it('should pass the component binding', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent, new Template({inline: '<div></div>'}));
tplResolver.setView(MainComponent, new View({template: '<div></div>'}));
var compiler = createCompiler([createRenderProtoView()], [createProtoView()]);
compiler.compile(MainComponent).then( (protoView) => {
var request = protoViewFactory.requests[0];
@@ -225,9 +225,9 @@ export function main() {
}));
it('should pass the directive bindings', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent,
new Template({
inline: '<div></div>',
tplResolver.setView(MainComponent,
new View({
template: '<div></div>',
directives: [SomeDecoratorDirective]
})
);
@@ -241,7 +241,7 @@ export function main() {
}));
it('should use the protoView of the ProtoViewFactory', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent, new Template({inline: '<div></div>'}));
tplResolver.setView(MainComponent, new View({template: '<div></div>'}));
var renderProtoView = createRenderProtoView();
var expectedProtoView = createProtoView();
var compiler = createCompiler([renderProtoView], [expectedProtoView]);
@@ -254,8 +254,8 @@ export function main() {
});
it('should load nested components', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent, new Template({inline: '<div></div>'}));
tplResolver.setTemplate(NestedComponent, new Template({inline: '<div></div>'}));
tplResolver.setView(MainComponent, new View({template: '<div></div>'}));
tplResolver.setView(NestedComponent, new View({template: '<div></div>'}));
var mainProtoView = createProtoView([
createComponentElementBinder(reader, NestedComponent)
]);
@@ -278,8 +278,8 @@ export function main() {
}));
it('should load nested components in viewport', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent, new Template({inline: '<div></div>'}));
tplResolver.setTemplate(NestedComponent, new Template({inline: '<div></div>'}));
tplResolver.setView(MainComponent, new View({template: '<div></div>'}));
tplResolver.setView(NestedComponent, new View({template: '<div></div>'}));
var mainProtoView = createProtoView([
createViewportElementBinder(null)
]);
@@ -314,7 +314,7 @@ export function main() {
}));
it('should cache compiled components', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent, new Template({inline: '<div></div>'}));
tplResolver.setView(MainComponent, new View({template: '<div></div>'}));
var renderProtoView = createRenderProtoView();
var expectedProtoView = createProtoView();
var compiler = createCompiler([renderProtoView], [expectedProtoView]);
@@ -328,7 +328,7 @@ export function main() {
}));
it('should re-use components being compiled', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent, new Template({inline: '<div></div>'}));
tplResolver.setView(MainComponent, new View({template: '<div></div>'}));
var renderProtoViewCompleter = PromiseWrapper.completer();
var expectedProtoView = createProtoView();
var compiler = createCompiler([renderProtoViewCompleter.promise], [expectedProtoView]);
@@ -344,7 +344,7 @@ export function main() {
}));
it('should allow recursive components', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent, new Template({inline: '<div></div>'}));
tplResolver.setView(MainComponent, new View({template: '<div></div>'}));
var mainProtoView = createProtoView([
createComponentElementBinder(reader, MainComponent)
]);
@@ -362,7 +362,7 @@ export function main() {
}));
it('should create root proto views', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MainComponent, new Template({inline: '<div></div>'}));
tplResolver.setView(MainComponent, new View({template: '<div></div>'}));
var rootProtoView = createProtoView([
createComponentElementBinder(reader, MainComponent)
]);
@@ -388,7 +388,7 @@ function createDirectiveBinding(reader, type) {
}
function createProtoView(elementBinders = null) {
var pv = new ProtoView(null, null, null);
var pv = new AppProtoView(null, null, null);
if (isBlank(elementBinders)) {
elementBinders = [];
}
@@ -419,7 +419,7 @@ function createRenderProtoView(elementBinders = null) {
if (isBlank(elementBinders)) {
elementBinders = [];
}
return new renderApi.ProtoView({
return new renderApi.ProtoViewDto({
elementBinders: elementBinders
});
}
@@ -463,12 +463,12 @@ class SomeDecoratorDirective {}
class IgnoreChildrenDecoratorDirective {}
@Decorator({
events: {'someEvent': 'someAction'}
hostListeners: {'someEvent': 'someAction'}
})
class DirectiveWithEvents {}
@Decorator({
bind: {'a': 'b'}
properties: {'a': 'b'}
})
class DirectiveWithBind {}
@@ -483,7 +483,7 @@ class DirectiveWithAttributes {
}
class FakeRenderer extends renderApi.Renderer {
requests:List<renderApi.Template>;
requests:List<renderApi.ViewDefinition>;
_results:List;
constructor(results) {
@@ -492,12 +492,12 @@ class FakeRenderer extends renderApi.Renderer {
this.requests = [];
}
compile(template:renderApi.Template):Promise<renderApi.ProtoView> {
compile(template:renderApi.ViewDefinition):Promise<renderApi.ProtoViewDto> {
ListWrapper.push(this.requests, template);
return PromiseWrapper.resolve(ListWrapper.removeAt(this._results, 0));
}
createRootProtoView(elementOrSelector, componentId):Promise<renderApi.ProtoView> {
createRootProtoView(elementOrSelector, componentId):Promise<renderApi.ProtoViewDto> {
return PromiseWrapper.resolve(
createRenderProtoView([createRenderComponentElementBinder(0)])
);
@@ -512,7 +512,7 @@ class FakeUrlResolver extends UrlResolver {
resolve(baseUrl: string, url: string): string {
if (baseUrl === null && url == './') {
return 'http://www.app.com';
};
}
return baseUrl + url;
}
@@ -527,7 +527,7 @@ class FakeTemplateResolver extends TemplateResolver {
this._cmpTemplates = MapWrapper.create();
}
resolve(component: Type): Template {
resolve(component: Type): View {
var template = MapWrapper.get(this._cmpTemplates, component);
if (isBlank(template)) {
throw 'No template';
@@ -535,7 +535,7 @@ class FakeTemplateResolver extends TemplateResolver {
return template;
}
setTemplate(component: Type, template: Template) {
setView(component: Type, template: View) {
MapWrapper.set(this._cmpTemplates, component, template);
}
}
@@ -550,8 +550,8 @@ class FakeProtoViewFactory extends ProtoViewFactory {
this._results = results;
}
createProtoView(componentBinding:DirectiveBinding, renderProtoView: renderApi.ProtoView, directives:List<DirectiveBinding>):ProtoView {
createProtoView(componentBinding:DirectiveBinding, renderProtoView: renderApi.ProtoViewDto, directives:List<DirectiveBinding>):AppProtoView {
ListWrapper.push(this.requests, [componentBinding, renderProtoView, directives]);
return ListWrapper.removeAt(this._results, 0);
}
}
}
@@ -6,7 +6,7 @@ import {Parent, Ancestor} from 'angular2/src/core/annotations/visibility';
import {EventEmitter, PropertySetter, 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 {ProtoView, View} from 'angular2/src/core/compiler/view';
import {AppProtoView, AppView} from 'angular2/src/core/compiler/view';
import {ViewContainer} from 'angular2/src/core/compiler/view_container';
import {NgElement} from 'angular2/src/core/compiler/ng_element';
import {Directive} from 'angular2/src/core/annotations/annotations';
@@ -20,7 +20,7 @@ class DummyDirective extends Directive {
}
@proxy
@IMPLEMENTS(View)
@IMPLEMENTS(AppView)
class DummyView extends SpyObject {noSuchMethod(m){super.noSuchMethod(m)}}
@@ -180,7 +180,7 @@ class B_Needs_A {
class NeedsView {
view:any;
constructor(@Inject(View) view) {
constructor(@Inject(AppView) view) {
this.view = view;
}
}
@@ -596,7 +596,7 @@ export function main() {
var view = new DummyView();
var inj = injector([], null, null, new PreBuiltObjects(view, null, null, null));
expect(inj.get(View)).toEqual(view);
expect(inj.get(AppView)).toEqual(view);
});
it("should return element", function () {
@@ -699,11 +699,11 @@ export function main() {
function createpreBuildObject(eventName, eventHandler) {
var handlers = StringMapWrapper.create();
StringMapWrapper.set(handlers, eventName, eventHandler);
var pv = new ProtoView(null, null, null);
var pv = new AppProtoView(null, null, null);
pv.bindElement(null, 0, null, null, null);
pv.bindEvent(eventName, new Parser(new Lexer()).parseAction('handler()', ''));
var view = new View(pv, MapWrapper.create());
var view = new AppView(pv, MapWrapper.create());
view.context = new ContextWithHandler(eventHandler);
return new PreBuiltObjects(view, null, null, null);
}
@@ -742,8 +742,8 @@ export function main() {
beforeEach( () => {
renderer = new FakeRenderer();
var protoView = new ProtoView(renderer, null, null);
view = new View(protoView, MapWrapper.create());
var protoView = new AppProtoView(renderer, null, null);
view = new AppView(protoView, MapWrapper.create());
view.render = new ViewRef();
});
+83 -83
View File
@@ -25,7 +25,7 @@ import {dynamicChangeDetection,
ChangeDetection, DynamicChangeDetection, Pipe, PipeRegistry, BindingPropagationConfig, ON_PUSH} from 'angular2/change_detection';
import {Decorator, Component, Viewport, DynamicComponent} from 'angular2/src/core/annotations/annotations';
import {Template} from 'angular2/src/core/annotations/template';
import {View} from 'angular2/src/core/annotations/view';
import {Parent, Ancestor} from 'angular2/src/core/annotations/visibility';
import {EventEmitter, Attribute} from 'angular2/src/core/annotations/di';
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
@@ -45,7 +45,7 @@ export function main() {
describe('react to record changes', function() {
it('should consume text node changes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({inline: '<div>{{ctxProp}}</div>'}));
tb.overrideView(MyComp, new View({template: '<div>{{ctxProp}}</div>'}));
tb.createView(MyComp, {context: ctx}).then((view) => {
ctx.ctxProp = 'Hello World!';
@@ -56,7 +56,7 @@ export function main() {
}));
it('should consume element binding changes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({inline: '<div [id]="ctxProp"></div>'}));
tb.overrideView(MyComp, new View({template: '<div [id]="ctxProp"></div>'}));
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -69,7 +69,7 @@ export function main() {
}));
it('should consume binding to aria-* attributes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({inline: '<div [attr.aria-label]="ctxProp"></div>'}));
tb.overrideView(MyComp, new View({template: '<div [attr.aria-label]="ctxProp"></div>'}));
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -86,7 +86,7 @@ export function main() {
}));
it('should consume binding to property names where attr name and property name do not match', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({inline: '<div [tabindex]="ctxNumProp"></div>'}));
tb.overrideView(MyComp, new View({template: '<div [tabindex]="ctxNumProp"></div>'}));
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -102,7 +102,7 @@ export function main() {
}));
it('should consume binding to camel-cased properties using dash-cased syntax in templates', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({inline: '<input [read-only]="ctxBoolProp">'}));
tb.overrideView(MyComp, new View({template: '<input [read-only]="ctxBoolProp">'}));
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -118,7 +118,7 @@ export function main() {
}));
it('should consume binding to inner-html', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({inline: '<div inner-html="{{ctxProp}}"></div>'}));
tb.overrideView(MyComp, new View({template: '<div inner-html="{{ctxProp}}"></div>'}));
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -135,7 +135,7 @@ export function main() {
}));
it('should ignore bindings to unknown properties', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({inline: '<div unknown="{{ctxProp}}"></div>'}));
tb.overrideView(MyComp, new View({template: '<div unknown="{{ctxProp}}"></div>'}));
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -155,7 +155,7 @@ export function main() {
'<div my-dir elprop="Hi {{\'there!\'}}"></div>' +
'<div my-dir elprop="One more {{ctxProp}}"></div>' +
'</div>'
tb.overrideTemplate(MyComp, new Template({inline: tpl, directives: [MyDir]}));
tb.overrideView(MyComp, new View({template: tpl, directives: [MyDir]}));
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -181,9 +181,9 @@ export function main() {
});
it("should support pipes in bindings and bind config", inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp,
new Template({
inline: '<component-with-pipes #comp [prop]="ctxProp | double"></component-with-pipes>',
tb.overrideView(MyComp,
new View({
template: '<component-with-pipes #comp [prop]="ctxProp | double"></component-with-pipes>',
directives: [ComponentWithPipes]
}));
@@ -202,8 +202,8 @@ export function main() {
});
it('should support nested components.', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<child-cmp></child-cmp>',
tb.overrideView(MyComp, new View({
template: '<child-cmp></child-cmp>',
directives: [ChildComp]
}));
@@ -218,9 +218,9 @@ export function main() {
// GH issue 328 - https://github.com/angular/angular/issues/328
it('should support different directive types on a single node', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp,
new Template({
inline: '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>',
tb.overrideView(MyComp,
new View({
template: '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>',
directives: [MyDir, ChildComp]
}));
@@ -238,10 +238,10 @@ export function main() {
}));
it('should support directives where a binding attribute is not given', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp,
new Template({
tb.overrideView(MyComp,
new View({
// No attribute "el-prop" specified.
inline: '<p my-dir></p>',
template: '<p my-dir></p>',
directives: [MyDir]
}));
@@ -251,9 +251,9 @@ export function main() {
}));
it('should support directives where a selector matches property binding', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp,
new Template({
inline: '<p [id]="ctxProp"></p>',
tb.overrideView(MyComp,
new View({
template: '<p [id]="ctxProp"></p>',
directives: [IdComponent]
}));
@@ -274,9 +274,9 @@ export function main() {
}));
it('should support template directives via `<template>` elements.', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp,
new Template({
inline: '<div><template some-viewport var-greeting="some-tmpl"><copy-me>{{greeting}}</copy-me></template></div>',
tb.overrideView(MyComp,
new View({
template: '<div><template some-viewport var-greeting="some-tmpl"><copy-me>{{greeting}}</copy-me></template></div>',
directives: [SomeViewport]
}));
@@ -294,8 +294,8 @@ export function main() {
}));
it('should support template directives via `template` attribute.', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<div><copy-me template="some-viewport: var greeting=some-tmpl">{{greeting}}</copy-me></div>',
tb.overrideView(MyComp, new View({
template: '<div><copy-me template="some-viewport: var greeting=some-tmpl">{{greeting}}</copy-me></div>',
directives: [SomeViewport]
}));
@@ -313,8 +313,8 @@ export function main() {
}));
it('should assign the component instance to a var-', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<p><child-cmp var-alice></child-cmp></p>',
tb.overrideView(MyComp, new View({
template: '<p><child-cmp var-alice></child-cmp></p>',
directives: [ChildComp]
}));
@@ -328,8 +328,8 @@ export function main() {
}));
it('should assign two component instances each with a var-', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<p><child-cmp var-alice></child-cmp><child-cmp var-bob></p>',
tb.overrideView(MyComp, new View({
template: '<p><child-cmp var-alice></child-cmp><child-cmp var-bob></p>',
directives: [ChildComp]
}));
@@ -345,8 +345,8 @@ export function main() {
}));
it('should assign the component instance to a var- with shorthand syntax', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<child-cmp #alice></child-cmp>',
tb.overrideView(MyComp, new View({
template: '<child-cmp #alice></child-cmp>',
directives: [ChildComp]
}));
@@ -360,8 +360,8 @@ export function main() {
}));
it('should assign the element instance to a user-defined variable', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp,
new Template({inline: '<p><div var-alice><i>Hello</i></div></p>'}));
tb.overrideView(MyComp,
new View({template: '<p><div var-alice><i>Hello</i></div></p>'}));
tb.createView(MyComp, {context: ctx}).then((view) => {
expect(view.rawView.locals).not.toBe(null);
@@ -376,8 +376,8 @@ export function main() {
it('should assign the element instance to a user-defined variable with camelCase using dash-case', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp,
new Template({inline: '<p><div var-super-alice><i>Hello</i></div></p>'}));
tb.overrideView(MyComp,
new View({template: '<p><div var-super-alice><i>Hello</i></div></p>'}));
tb.createView(MyComp, {context: ctx}).then((view) => {
expect(view.rawView.locals).not.toBe(null);
@@ -394,8 +394,8 @@ export function main() {
it("can be used to disable the change detection of the component's template",
inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<push-cmp #cmp></push-cmp>',
tb.overrideView(MyComp, new View({
template: '<push-cmp #cmp></push-cmp>',
directives: [[[PushBasedComp]]]
}));
@@ -418,8 +418,8 @@ export function main() {
}));
it('should not affect updating properties on the component', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
tb.overrideView(MyComp, new View({
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
directives: [[[PushBasedComp]]]
}));
@@ -441,8 +441,8 @@ export function main() {
});
it('should create a component that injects a @Parent', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<some-directive><cmp-with-parent #child></cmp-with-parent></some-directive>',
tb.overrideView(MyComp, new View({
template: '<some-directive><cmp-with-parent #child></cmp-with-parent></some-directive>',
directives: [SomeDirective, CompWithParent]
}));
@@ -456,8 +456,8 @@ export function main() {
}));
it('should create a component that injects an @Ancestor', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: `
tb.overrideView(MyComp, new View({
template: `
<some-directive>
<p>
<cmp-with-ancestor #child></cmp-with-ancestor>
@@ -476,8 +476,8 @@ export function main() {
}));
it('should create a component that injects an @Ancestor through viewport directive', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: `
tb.overrideView(MyComp, new View({
template: `
<some-directive>
<p *if="true">
<cmp-with-ancestor #child></cmp-with-ancestor>
@@ -498,8 +498,8 @@ export function main() {
}));
it('should support events via EventEmitter', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<div emitter listener></div>',
tb.overrideView(MyComp, new View({
template: '<div emitter listener></div>',
directives: [DecoratorEmitingEvent, DecoratorListeningEvent]
}));
@@ -523,8 +523,8 @@ export function main() {
if (DOM.supportsDOMEvents()) {
it('should support render events', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<div listener></div>',
tb.overrideView(MyComp, new View({
template: '<div listener></div>',
directives: [DecoratorListeningDomEvent]
}));
@@ -545,8 +545,8 @@ export function main() {
describe("dynamic components", () => {
it('should support loading components dynamically', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<dynamic-comp #dynamic></dynamic-comp>',
tb.overrideView(MyComp, new View({
template: '<dynamic-comp #dynamic></dynamic-comp>',
directives: [DynamicComp]
}));
@@ -563,8 +563,8 @@ export function main() {
}));
it('should inject dependencies of the dynamically-loaded component', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<dynamic-comp #dynamic></dynamic-comp>',
tb.overrideView(MyComp, new View({
template: '<dynamic-comp #dynamic></dynamic-comp>',
directives: [DynamicComp]
}));
@@ -579,8 +579,8 @@ export function main() {
});
it('should support static attributes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideTemplate(MyComp, new Template({
inline: '<input static type="text" title></input>',
tb.overrideView(MyComp, new View({
template: '<input static type="text" title>',
directives: [NeedsAttribute]
}));
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -605,7 +605,7 @@ export function main() {
if (assertionsEnabled()) {
function expectCompileError(tb, inlineTpl, errMessage, done) {
tb.overrideTemplate(MyComp, new Template({inline: inlineTpl}));
tb.overrideView(MyComp, new View({template: inlineTpl}));
PromiseWrapper.then(tb.createView(MyComp),
(value) => {
throw new BaseException("Test failure: should not have come here as an exception was expected");
@@ -673,10 +673,10 @@ class DynamicComp {
@Component({
selector: 'hello-cmp',
services: [DynamicallyCreatedComponentService]
injectables: [DynamicallyCreatedComponentService]
})
@Template({
inline: "{{greeting}}"
@View({
template: "{{greeting}}"
})
class DynamicallyCreatedCmp {
greeting:string;
@@ -689,7 +689,7 @@ class DynamicallyCreatedCmp {
@Decorator({
selector: '[my-dir]',
bind: {'dirProp':'elprop'}
properties: {'dirProp':'elprop'}
})
class MyDir {
dirProp:string;
@@ -700,12 +700,12 @@ class MyDir {
@Component({
selector: 'push-cmp',
bind: {
properties: {
'prop': 'prop'
},
changeDetection:ON_PUSH
})
@Template({inline: '{{field}}'})
@View({template: '{{field}}'})
class PushBasedComp {
numberOfChecks:number;
bpc:BindingPropagationConfig;
@@ -727,7 +727,7 @@ class PushBasedComp {
}
@Component()
@Template({directives: [
@View({directives: [
]})
class MyComp {
ctxProp:string;
@@ -743,12 +743,12 @@ class MyComp {
@Component({
selector: 'component-with-pipes',
bind: {
properties: {
"prop": "prop | double"
}
})
@Template({
inline: ''
@View({
template: ''
})
class ComponentWithPipes {
prop:string;
@@ -756,11 +756,11 @@ class ComponentWithPipes {
@Component({
selector: 'child-cmp',
services: [MyService]
injectables: [MyService]
})
@Template({
@View({
directives: [MyDir],
inline: '{{ctxProp}}'
template: '{{ctxProp}}'
})
class ChildComp {
ctxProp:string;
@@ -779,8 +779,8 @@ class SomeDirective { }
@Component({
selector: 'cmp-with-parent'
})
@Template({
inline: '<p>Component with an injected parent</p>',
@View({
template: '<p>Component with an injected parent</p>',
directives: [SomeDirective]
})
class CompWithParent {
@@ -793,8 +793,8 @@ class CompWithParent {
@Component({
selector: 'cmp-with-ancestor'
})
@Template({
inline: '<p>Component with an injected ancestor</p>',
@View({
template: '<p>Component with an injected ancestor</p>',
directives: [SomeDirective]
})
class CompWithAncestor {
@@ -806,7 +806,7 @@ class CompWithAncestor {
@Component({
selector: '[child-cmp2]',
services: [MyService]
injectables: [MyService]
})
class ChildComp2 {
ctxProp:string;
@@ -856,7 +856,7 @@ class DoublePipeFactory {
@Decorator({
selector: '[emitter]',
events: {'event': 'onEvent($event)'}
hostListeners: {'event': 'onEvent($event)'}
})
class DecoratorEmitingEvent {
msg: string;
@@ -878,7 +878,7 @@ class DecoratorEmitingEvent {
@Decorator({
selector: '[listener]',
events: {'event': 'onEvent($event)'}
hostListeners: {'event': 'onEvent($event)'}
})
class DecoratorListeningEvent {
msg: string;
@@ -894,7 +894,7 @@ class DecoratorListeningEvent {
@Decorator({
selector: '[listener]',
events: {'domEvent': 'onEvent($event.type)'}
hostListeners: {'domEvent': 'onEvent($event.type)'}
})
class DecoratorListeningDomEvent {
eventType: string;
@@ -910,10 +910,10 @@ class DecoratorListeningDomEvent {
@Component({
selector: '[id]',
bind: {'id': 'id'}
properties: {'id': 'id'}
})
@Template({
inline: '<div>Matched on id with {{id}}</div>'
@View({
template: '<div>Matched on id with {{id}}</div>'
})
class IdComponent {
id: string;
@@ -17,7 +17,7 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
import {QueryList} from 'angular2/src/core/compiler/query_list';
import {Query} from 'angular2/src/core/annotations/di';
import {Decorator, Component, Template, If, For} from 'angular2/angular2';
import {Decorator, Component, View, If, For} from 'angular2/angular2';
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
@@ -84,9 +84,9 @@ export function main() {
}
@Component({selector: 'needs-query'})
@Template({
@View({
directives: [For],
inline: '<div *for="var dir of query">{{dir.text}}|</div>'
template: '<div *for="var dir of query">{{dir.text}}|</div>'
})
class NeedsQuery {
query: QueryList;
@@ -99,7 +99,7 @@ var _constructiontext = 0;
@Decorator({
selector: '[text]',
bind: {
properties: {
'text': 'text'
}
})
@@ -109,7 +109,7 @@ class TextDirective {
}
@Component({selector: 'my-comp'})
@Template({
@View({
directives: [NeedsQuery, TextDirective, If, For]
})
class MyComp {