chore(rename): rename View and Template concepts for #1244
This commit is contained in:

committed by
Jeremy Elbourn

parent
564477b8a0
commit
bf7933714a
14
modules/angular2/test/core/application_spec.js
vendored
14
modules/angular2/test/core/application_spec.js
vendored
@ -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');
|
||||
|
@ -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();
|
||||
});
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
|
||||
import {StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {Template} from 'angular2/src/core/annotations/template';
|
||||
import {View} from 'angular2/src/core/annotations/view';
|
||||
import {Component} from 'angular2/src/core/annotations/annotations';
|
||||
|
||||
import {TestBed} from 'angular2/src/test_lib/test_bed';
|
||||
@ -141,7 +141,7 @@ export function main() {
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@Template({directives: [CSSClass]})
|
||||
@View({directives: [CSSClass]})
|
||||
class TestComponent {
|
||||
condition:boolean;
|
||||
expr;
|
||||
|
4
modules/angular2/test/directives/for_spec.js
vendored
4
modules/angular2/test/directives/for_spec.js
vendored
@ -16,7 +16,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {Component} from 'angular2/src/core/annotations/annotations';
|
||||
import {Template} from 'angular2/src/core/annotations/template';
|
||||
import {View} from 'angular2/src/core/annotations/view';
|
||||
|
||||
import {For} from 'angular2/src/directives/for';
|
||||
|
||||
@ -231,7 +231,7 @@ class Foo {
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@Template({directives: [For]})
|
||||
@View({directives: [For]})
|
||||
class TestComponent {
|
||||
items: any;
|
||||
constructor() {
|
||||
|
4
modules/angular2/test/directives/if_spec.js
vendored
4
modules/angular2/test/directives/if_spec.js
vendored
@ -17,7 +17,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {TestBed} from 'angular2/src/test_lib/test_bed';
|
||||
|
||||
import {Component} from 'angular2/src/core/annotations/annotations';
|
||||
import {Template} from 'angular2/src/core/annotations/template';
|
||||
import {View} from 'angular2/src/core/annotations/view';
|
||||
|
||||
import {If} from 'angular2/src/directives/if';
|
||||
|
||||
@ -183,7 +183,7 @@ export function main() {
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@Template({directives: [If]})
|
||||
@View({directives: [If]})
|
||||
class TestComponent {
|
||||
booleanCondition: boolean;
|
||||
nestedBooleanCondition: boolean;
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {Decorator, Component} from 'angular2/src/core/annotations/annotations';
|
||||
import {Template} from 'angular2/src/core/annotations/template';
|
||||
import {View} from 'angular2/src/core/annotations/view';
|
||||
|
||||
import {NgElement} from 'angular2/src/core/compiler/ng_element';
|
||||
|
||||
@ -55,7 +55,7 @@ export function main() {
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@Template({directives: [NonBindable, TestDecorator]})
|
||||
@View({directives: [NonBindable, TestDecorator]})
|
||||
class TestComponent {
|
||||
text: string;
|
||||
constructor() {
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {Component} from 'angular2/src/core/annotations/annotations';
|
||||
import {Template} from 'angular2/src/core/annotations/template';
|
||||
import {View} from 'angular2/src/core/annotations/view';
|
||||
|
||||
import {Switch, SwitchWhen, SwitchDefault} from 'angular2/src/directives/switch';
|
||||
|
||||
@ -139,7 +139,7 @@ export function main() {
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@Template({directives: [Switch, SwitchWhen, SwitchDefault]})
|
||||
@View({directives: [Switch, SwitchWhen, SwitchDefault]})
|
||||
class TestComponent {
|
||||
switchValue: any;
|
||||
when1: any;
|
||||
|
@ -16,7 +16,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {Inject} from 'angular2/di';
|
||||
|
||||
import {Component, Decorator, Template, PropertySetter} from 'angular2/angular2';
|
||||
import {Component, Decorator, View, PropertySetter} from 'angular2/angular2';
|
||||
|
||||
import {TestBed} from 'angular2/src/test_lib/test_bed';
|
||||
|
||||
@ -367,7 +367,7 @@ export function main() {
|
||||
}
|
||||
|
||||
@Component({selector: "my-comp"})
|
||||
@Template({directives: [
|
||||
@View({directives: [
|
||||
ControlGroupDirective,
|
||||
ControlDirective,
|
||||
WrappedValue,
|
||||
@ -386,7 +386,7 @@ class MyComp {
|
||||
|
||||
@Decorator({
|
||||
selector:'[wrapped-value]',
|
||||
events: {
|
||||
hostListeners: {
|
||||
'change' : 'handleOnChange($event.target.value)'
|
||||
}
|
||||
})
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock';
|
||||
|
||||
import {Component} from 'angular2/src/core/annotations/annotations';
|
||||
import {Template} from 'angular2/src/core/annotations/template';
|
||||
import {View} from 'angular2/src/core/annotations/view';
|
||||
|
||||
import {isBlank} from 'angular2/src/facade/lang';
|
||||
|
||||
@ -23,17 +23,17 @@ export function main() {
|
||||
resolver = new MockTemplateResolver();
|
||||
});
|
||||
|
||||
describe('Template overriding', () => {
|
||||
describe('View overriding', () => {
|
||||
it('should fallback to the default TemplateResolver when templates are not overridden', () => {
|
||||
var template = resolver.resolve(SomeComponent);
|
||||
expect(template.inline).toEqual('template');
|
||||
expect(template.template).toEqual('template');
|
||||
expect(template.directives).toEqual([SomeDirective]);
|
||||
});
|
||||
|
||||
it('should allow overriding a template', () => {
|
||||
resolver.setTemplate(SomeComponent, new Template({inline: 'overridden template'}));
|
||||
it('should allow overriding the @View', () => {
|
||||
resolver.setView(SomeComponent, new View({template: 'overridden template'}));
|
||||
var template = resolver.resolve(SomeComponent);
|
||||
expect(template.inline).toEqual('overridden template');
|
||||
expect(template.template).toEqual('overridden template');
|
||||
expect(isBlank(template.directives)).toBe(true);
|
||||
|
||||
});
|
||||
@ -41,24 +41,24 @@ export function main() {
|
||||
it('should not allow overriding a template after it has been resolved', () => {
|
||||
resolver.resolve(SomeComponent);
|
||||
expect(() => {
|
||||
resolver.setTemplate(SomeComponent, new Template({inline: 'overridden template'}));
|
||||
resolver.setView(SomeComponent, new View({template: 'overridden template'}));
|
||||
}).toThrowError('The component SomeComponent has already been compiled, its configuration can not be changed');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inline definition overriding', () => {
|
||||
it('should allow overriding the default Template', () => {
|
||||
describe('inline template definition overriding', () => {
|
||||
it('should allow overriding the default template', () => {
|
||||
resolver.setInlineTemplate(SomeComponent, 'overridden template');
|
||||
var template = resolver.resolve(SomeComponent);
|
||||
expect(template.inline).toEqual('overridden template');
|
||||
expect(template.template).toEqual('overridden template');
|
||||
expect(template.directives).toEqual([SomeDirective]);
|
||||
});
|
||||
|
||||
it('should allow overriding an overriden template', () => {
|
||||
resolver.setTemplate(SomeComponent, new Template({inline: 'overridden template'}));
|
||||
it('should allow overriding an overriden @View', () => {
|
||||
resolver.setView(SomeComponent, new View({template: 'overridden template'}));
|
||||
resolver.setInlineTemplate(SomeComponent, 'overridden template x 2');
|
||||
var template = resolver.resolve(SomeComponent);
|
||||
expect(template.inline).toEqual('overridden template x 2');
|
||||
expect(template.template).toEqual('overridden template x 2');
|
||||
});
|
||||
|
||||
it('should not allow overriding a template after it has been resolved', () => {
|
||||
@ -78,8 +78,8 @@ export function main() {
|
||||
expect(template.directives[0]).toBe(SomeOtherDirective);
|
||||
});
|
||||
|
||||
it('should allow overriding a directive from an overriden template', () => {
|
||||
resolver.setTemplate(SomeComponent, new Template({directives: [SomeOtherDirective]}));
|
||||
it('should allow overriding a directive from an overriden @View', () => {
|
||||
resolver.setView(SomeComponent, new View({directives: [SomeOtherDirective]}));
|
||||
resolver.overrideTemplateDirective(SomeComponent, SomeOtherDirective, SomeComponent);
|
||||
var template = resolver.resolve(SomeComponent);
|
||||
expect(template.directives.length).toEqual(1);
|
||||
@ -103,8 +103,8 @@ export function main() {
|
||||
}
|
||||
|
||||
@Component({selector: 'cmp'})
|
||||
@Template({
|
||||
inline: 'template',
|
||||
@View({
|
||||
template: 'template',
|
||||
directives: [SomeDirective],
|
||||
})
|
||||
class SomeComponent {
|
||||
|
@ -17,7 +17,7 @@ import {Type, isBlank, stringify, isPresent} from 'angular2/src/facade/lang';
|
||||
import {PromiseWrapper, Promise} from 'angular2/src/facade/async';
|
||||
|
||||
import {Compiler, CompilerCache} from 'angular2/src/render/dom/compiler/compiler';
|
||||
import {ProtoView, Template} from 'angular2/src/render/api';
|
||||
import {ProtoViewDto, ViewDefinition} from 'angular2/src/render/api';
|
||||
import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element';
|
||||
import {CompileStep} from 'angular2/src/render/dom/compiler/compile_step'
|
||||
import {CompileStepFactory} from 'angular2/src/render/dom/compiler/compile_step_factory';
|
||||
@ -39,13 +39,13 @@ export function runCompilerCommonTests() {
|
||||
return new Compiler(mockStepFactory, tplLoader);
|
||||
}
|
||||
|
||||
it('should run the steps and build the ProtoView of the root element', inject([AsyncTestCompleter], (async) => {
|
||||
it('should run the steps and build the AppProtoView of the root element', inject([AsyncTestCompleter], (async) => {
|
||||
var compiler = createCompiler((parent, current, control) => {
|
||||
current.inheritedProtoView.bindVariable('b', 'a');
|
||||
});
|
||||
compiler.compile(new Template({
|
||||
compiler.compile(new ViewDefinition({
|
||||
componentId: 'someComponent',
|
||||
inline: '<div></div>'
|
||||
template: '<div></div>'
|
||||
})).then( (protoView) => {
|
||||
expect(protoView.variableBindings).toEqual(MapWrapper.createFromStringMap({
|
||||
'a': 'b'
|
||||
@ -56,9 +56,9 @@ export function runCompilerCommonTests() {
|
||||
|
||||
it('should use the inline template and compile in sync', inject([AsyncTestCompleter], (async) => {
|
||||
var compiler = createCompiler(EMPTY_STEP);
|
||||
compiler.compile(new Template({
|
||||
compiler.compile(new ViewDefinition({
|
||||
componentId: 'someId',
|
||||
inline: 'inline component'
|
||||
template: 'inline component'
|
||||
})).then( (protoView) => {
|
||||
expect(DOM.getInnerHTML(protoView.render.delegate.element)).toEqual('inline component');
|
||||
async.done();
|
||||
@ -70,7 +70,7 @@ export function runCompilerCommonTests() {
|
||||
'someUrl': 'url component'
|
||||
});
|
||||
var compiler = createCompiler(EMPTY_STEP, urlData);
|
||||
compiler.compile(new Template({
|
||||
compiler.compile(new ViewDefinition({
|
||||
componentId: 'someId',
|
||||
absUrl: 'someUrl'
|
||||
})).then( (protoView) => {
|
||||
@ -81,7 +81,7 @@ export function runCompilerCommonTests() {
|
||||
|
||||
it('should report loading errors', inject([AsyncTestCompleter], (async) => {
|
||||
var compiler = createCompiler(EMPTY_STEP, MapWrapper.create());
|
||||
PromiseWrapper.catchError(compiler.compile(new Template({
|
||||
PromiseWrapper.catchError(compiler.compile(new ViewDefinition({
|
||||
componentId: 'someId',
|
||||
absUrl: 'someUrl'
|
||||
})), (e) => {
|
||||
@ -102,9 +102,9 @@ export function runCompilerCommonTests() {
|
||||
});
|
||||
|
||||
// It should always return a Promise because the subtask is async
|
||||
var pvPromise = compiler.compile(new Template({
|
||||
var pvPromise = compiler.compile(new ViewDefinition({
|
||||
componentId: 'someId',
|
||||
inline: 'some component'
|
||||
template: 'some component'
|
||||
}));
|
||||
expect(pvPromise).toBePromise();
|
||||
expect(subTasksCompleted).toEqual(false);
|
||||
@ -159,9 +159,9 @@ class FakeTemplateLoader extends TemplateLoader {
|
||||
this._urlData = urlData;
|
||||
}
|
||||
|
||||
load(template: Template) {
|
||||
if (isPresent(template.inline)) {
|
||||
return PromiseWrapper.resolve(DOM.createTemplate(template.inline));
|
||||
load(template: ViewDefinition) {
|
||||
if (isPresent(template.template)) {
|
||||
return PromiseWrapper.resolve(DOM.createTemplate(template.template));
|
||||
}
|
||||
|
||||
if (isPresent(template.absUrl)) {
|
||||
|
@ -6,7 +6,7 @@ import {CompilePipeline} from 'angular2/src/render/dom/compiler/compile_pipeline
|
||||
import {CompileStep} from 'angular2/src/render/dom/compiler/compile_step';
|
||||
import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element';
|
||||
import {CompileControl} from 'angular2/src/render/dom/compiler/compile_control';
|
||||
import {Template, DirectiveMetadata} from 'angular2/src/render/api';
|
||||
import {ViewDefinition, DirectiveMetadata} from 'angular2/src/render/api';
|
||||
import {Lexer, Parser} from 'angular2/change_detection';
|
||||
|
||||
export function main() {
|
||||
@ -232,7 +232,7 @@ var someDecoratorIgnoringChildren = new DirectiveMetadata({
|
||||
|
||||
var someDecoratorWithProps = new DirectiveMetadata({
|
||||
selector: '[some-decor-props]',
|
||||
bind: MapWrapper.createFromStringMap({
|
||||
properties: MapWrapper.createFromStringMap({
|
||||
'dirProp': 'elProp',
|
||||
'doubleProp': 'elProp | double'
|
||||
}),
|
||||
@ -242,7 +242,7 @@ var someDecoratorWithProps = new DirectiveMetadata({
|
||||
|
||||
var someDecoratorWithEvents = new DirectiveMetadata({
|
||||
selector: '[some-decor-events]',
|
||||
events: MapWrapper.createFromStringMap({
|
||||
hostListeners: MapWrapper.createFromStringMap({
|
||||
'click': 'doIt()'
|
||||
})
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
|
||||
import {Template} from 'angular2/src/render/api';
|
||||
import {ViewDefinition} from 'angular2/src/render/api';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {MockXHR} from 'angular2/src/mock/xhr_mock';
|
||||
|
||||
@ -28,16 +28,16 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should load inline templates', inject([AsyncTestCompleter], (async) => {
|
||||
var template = new Template({inline: 'inline template'});
|
||||
var template = new ViewDefinition({template: 'template template'});
|
||||
loader.load(template).then( (el) => {
|
||||
expect(DOM.content(el)).toHaveText('inline template');
|
||||
expect(DOM.content(el)).toHaveText('template template');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should load templates through XHR', inject([AsyncTestCompleter], (async) => {
|
||||
xhr.expect('base/foo', 'xhr template');
|
||||
var template = new Template({absUrl: 'base/foo'});
|
||||
var template = new ViewDefinition({absUrl: 'base/foo'});
|
||||
loader.load(template).then((el) => {
|
||||
expect(DOM.content(el)).toHaveText('xhr template');
|
||||
async.done();
|
||||
@ -48,7 +48,7 @@ export function main() {
|
||||
it('should cache template loaded through XHR', inject([AsyncTestCompleter], (async) => {
|
||||
var firstEl;
|
||||
xhr.expect('base/foo', 'xhr template');
|
||||
var template = new Template({absUrl: 'base/foo'});
|
||||
var template = new ViewDefinition({absUrl: 'base/foo'});
|
||||
loader.load(template)
|
||||
.then((el) => {
|
||||
firstEl = el;
|
||||
@ -63,14 +63,14 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should throw when no template is defined', () => {
|
||||
var template = new Template({inline: null, absUrl: null});
|
||||
var template = new ViewDefinition({template: null, absUrl: null});
|
||||
expect(() => loader.load(template))
|
||||
.toThrowError('Templates should have either their url or inline property set');
|
||||
.toThrowError('View should have either the url or template property set');
|
||||
});
|
||||
|
||||
it('should return a rejected Promise when xhr loading fails', inject([AsyncTestCompleter], (async) => {
|
||||
xhr.expect('base/foo', null);
|
||||
var template = new Template({absUrl: 'base/foo'});
|
||||
var template = new ViewDefinition({absUrl: 'base/foo'});
|
||||
PromiseWrapper.then(loader.load(template),
|
||||
function(_) { throw 'Unexpected response'; },
|
||||
function(error) {
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {ProtoView, Template, ViewContainerRef, EventDispatcher, DirectiveMetadata} from 'angular2/src/render/api';
|
||||
import {ProtoViewDto, ViewDefinition, ViewContainerRef, EventDispatcher, DirectiveMetadata} from 'angular2/src/render/api';
|
||||
|
||||
import {IntegrationTestbed, LoggingEventDispatcher, FakeEvent} from './integration_testbed';
|
||||
|
||||
@ -53,9 +53,9 @@ export function main() {
|
||||
it('should add a static component', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer();
|
||||
renderer.createRootProtoView(rootEl, 'someComponentId').then( (rootProtoView) => {
|
||||
var template = new Template({
|
||||
var template = new ViewDefinition({
|
||||
componentId: 'someComponent',
|
||||
inline: 'hello',
|
||||
template: 'hello',
|
||||
directives: []
|
||||
});
|
||||
renderer.compile(template).then( (pv) => {
|
||||
@ -70,9 +70,9 @@ export function main() {
|
||||
it('should add a a dynamic component', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer();
|
||||
renderer.createRootProtoView(rootEl, 'someComponentId').then( (rootProtoView) => {
|
||||
var template = new Template({
|
||||
var template = new ViewDefinition({
|
||||
componentId: 'someComponent',
|
||||
inline: 'hello',
|
||||
template: 'hello',
|
||||
directives: []
|
||||
});
|
||||
renderer.compile(template).then( (pv) => {
|
||||
@ -87,9 +87,9 @@ export function main() {
|
||||
|
||||
it('should update text nodes', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'someComponent',
|
||||
inline: '{{a}}',
|
||||
template: '{{a}}',
|
||||
directives: []
|
||||
})]
|
||||
});
|
||||
@ -103,9 +103,9 @@ export function main() {
|
||||
|
||||
it('should update element properties', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'someComponent',
|
||||
inline: '<input [value]="someProp">',
|
||||
template: '<input [value]="someProp">',
|
||||
directives: []
|
||||
})]
|
||||
});
|
||||
@ -119,9 +119,9 @@ export function main() {
|
||||
|
||||
it('should add and remove views to and from containers', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'someComponent',
|
||||
inline: '<template>hello</template>',
|
||||
template: '<template>hello</template>',
|
||||
directives: []
|
||||
})]
|
||||
});
|
||||
@ -144,9 +144,9 @@ export function main() {
|
||||
|
||||
it('should cache views', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'someComponent',
|
||||
inline: '<template>hello</template>',
|
||||
template: '<template>hello</template>',
|
||||
directives: []
|
||||
})],
|
||||
viewCacheCapacity: 2
|
||||
@ -170,9 +170,9 @@ export function main() {
|
||||
// the event expression processing...
|
||||
xit('should handle events', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'someComponent',
|
||||
inline: '<input (change)="$event.target.value">',
|
||||
template: '<input (change)="$event.target.value">',
|
||||
directives: []
|
||||
})]
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {Parser, Lexer} from 'angular2/change_detection';
|
||||
import {DirectDomRenderer} from 'angular2/src/render/dom/direct_dom_renderer';
|
||||
import {Compiler} from 'angular2/src/render/dom/compiler/compiler';
|
||||
import {ProtoViewRef, ProtoView, Template, ViewContainerRef, EventDispatcher, DirectiveMetadata} from 'angular2/src/render/api';
|
||||
import {ProtoViewRef, ProtoViewDto, ViewDefinition, ViewContainerRef, EventDispatcher, DirectiveMetadata} from 'angular2/src/render/api';
|
||||
import {DefaultStepFactory} from 'angular2/src/render/dom/compiler/compile_step_factory';
|
||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
@ -20,7 +20,7 @@ export class IntegrationTestbed {
|
||||
renderer;
|
||||
parser;
|
||||
eventPlugin;
|
||||
_templates:Map<string, Template>;
|
||||
_templates:Map<string, ViewDefinition>;
|
||||
|
||||
constructor({urlData, viewCacheCapacity, shadowDomStrategy, templates}) {
|
||||
this._templates = MapWrapper.create();
|
||||
@ -48,7 +48,7 @@ export class IntegrationTestbed {
|
||||
this.renderer = new DirectDomRenderer(compiler, viewFactory, shadowDomStrategy);
|
||||
}
|
||||
|
||||
compile(rootEl, componentId):Promise<ProtoView> {
|
||||
compile(rootEl, componentId):Promise<ProtoViewDto> {
|
||||
return this.renderer.createRootProtoView(rootEl, componentId).then( (rootProtoView) => {
|
||||
return this._compileNestedProtoViews(rootProtoView, [
|
||||
new DirectiveMetadata({
|
||||
@ -59,13 +59,13 @@ export class IntegrationTestbed {
|
||||
});
|
||||
}
|
||||
|
||||
_compile(template):Promise<ProtoView> {
|
||||
_compile(template):Promise<ProtoViewDto> {
|
||||
return this.renderer.compile(template).then( (protoView) => {
|
||||
return this._compileNestedProtoViews(protoView, template.directives);
|
||||
});
|
||||
}
|
||||
|
||||
_compileNestedProtoViews(protoView, directives):Promise<ProtoView> {
|
||||
_compileNestedProtoViews(protoView, directives):Promise<ProtoViewDto> {
|
||||
var childComponentRenderPvRefs = [];
|
||||
var nestedPVPromises = [];
|
||||
ListWrapper.forEach(protoView.elementBinders, (elementBinder) => {
|
||||
@ -119,9 +119,9 @@ class FakeTemplateLoader extends TemplateLoader {
|
||||
this._urlData = urlData;
|
||||
}
|
||||
|
||||
load(template: Template) {
|
||||
if (isPresent(template.inline)) {
|
||||
return PromiseWrapper.resolve(DOM.createTemplate(template.inline));
|
||||
load(template: ViewDefinition) {
|
||||
if (isPresent(template.template)) {
|
||||
return PromiseWrapper.resolve(DOM.createTemplate(template.template));
|
||||
}
|
||||
|
||||
if (isPresent(template.absUrl)) {
|
||||
@ -188,4 +188,4 @@ export class FakeEvent {
|
||||
constructor(target) {
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import {
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
import {StyleUrlResolver} from 'angular2/src/render/dom/shadow_dom/style_url_resolver';
|
||||
import {StyleInliner} from 'angular2/src/render/dom/shadow_dom/style_inliner';
|
||||
import {View} from 'angular2/src/render/dom/view/view';
|
||||
import {RenderView} from 'angular2/src/render/dom/view/view';
|
||||
|
||||
export function main() {
|
||||
describe('EmulatedScoped', () => {
|
||||
@ -47,7 +47,7 @@ export function main() {
|
||||
it('should attach the view nodes as child of the host element', () => {
|
||||
var host = el('<div><span>original content</span></div>');
|
||||
var nodes = el('<div>view</div>');
|
||||
var view = new View(null, [nodes], [], [], [], []);
|
||||
var view = new RenderView(null, [nodes], [], [], [], []);
|
||||
|
||||
strategy.attachTemplate(host, view);
|
||||
var firstChild = DOM.firstChild(host);
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
} from 'angular2/src/render/dom/shadow_dom/util';
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
import {StyleUrlResolver} from 'angular2/src/render/dom/shadow_dom/style_url_resolver';
|
||||
import {View} from 'angular2/src/render/dom/view/view';
|
||||
import {RenderView} from 'angular2/src/render/dom/view/view';
|
||||
|
||||
export function main() {
|
||||
var strategy;
|
||||
@ -42,7 +42,7 @@ export function main() {
|
||||
it('should attach the view nodes as child of the host element', () => {
|
||||
var host = el('<div><span>original content</span></div>');
|
||||
var nodes = el('<div>view</div>');
|
||||
var view = new View(null, [nodes], [], [], [], []);
|
||||
var view = new RenderView(null, [nodes], [], [], [], []);
|
||||
|
||||
strategy.attachTemplate(host, view);
|
||||
var firstChild = DOM.firstChild(host);
|
||||
|
@ -4,11 +4,11 @@ import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {Content} from 'angular2/src/render/dom/shadow_dom/content_tag';
|
||||
import {LightDom} from 'angular2/src/render/dom/shadow_dom/light_dom';
|
||||
import {View} from 'angular2/src/render/dom/view/view';
|
||||
import {RenderView} from 'angular2/src/render/dom/view/view';
|
||||
import {ViewContainer} from 'angular2/src/render/dom/view/view_container';
|
||||
|
||||
@proxy
|
||||
@IMPLEMENTS(View)
|
||||
@IMPLEMENTS(RenderView)
|
||||
class FakeView {
|
||||
contentTags;
|
||||
viewContainers;
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
} from 'angular2/src/render/dom/shadow_dom/native_shadow_dom_strategy';
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
import {StyleUrlResolver} from 'angular2/src/render/dom/shadow_dom/style_url_resolver';
|
||||
import {View} from 'angular2/src/render/dom/view/view';
|
||||
import {RenderView} from 'angular2/src/render/dom/view/view';
|
||||
|
||||
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
@ -35,7 +35,7 @@ export function main() {
|
||||
it('should attach the view nodes to the shadow root', () => {
|
||||
var host = el('<div><span>original content</span></div>');
|
||||
var nodes = el('<div>view</div>');
|
||||
var view = new View(null, [nodes], [], [], [], []);
|
||||
var view = new RenderView(null, [nodes], [], [], [], []);
|
||||
|
||||
strategy.attachTemplate(host, view);
|
||||
var shadowRoot = DOM.getShadowRoot(host);
|
||||
|
@ -17,7 +17,7 @@ import {MapWrapper, ListWrapper, StringMapWrapper} from 'angular2/src/facade/col
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
|
||||
import {
|
||||
ProtoView, Template, ViewContainerRef, DirectiveMetadata
|
||||
ProtoViewDto, ViewDefinition, ViewContainerRef, DirectiveMetadata
|
||||
} from 'angular2/src/render/api';
|
||||
|
||||
import {EmulatedScopedShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/emulated_scoped_shadow_dom_strategy';
|
||||
@ -69,9 +69,9 @@ export function main() {
|
||||
|
||||
it('should support simple components', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'main',
|
||||
inline: '<simple>' +
|
||||
template: '<simple>' +
|
||||
'<div>A</div>' +
|
||||
'</simple>',
|
||||
directives: [simple]
|
||||
@ -88,9 +88,9 @@ export function main() {
|
||||
|
||||
it('should support multiple content tags', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'main',
|
||||
inline: '<multiple-content-tags>' +
|
||||
template: '<multiple-content-tags>' +
|
||||
'<div>B</div>' +
|
||||
'<div>C</div>' +
|
||||
'<div class="left">A</div>' +
|
||||
@ -109,9 +109,9 @@ export function main() {
|
||||
|
||||
it('should redistribute only direct children', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'main',
|
||||
inline: '<multiple-content-tags>' +
|
||||
template: '<multiple-content-tags>' +
|
||||
'<div>B<div class="left">A</div></div>' +
|
||||
'<div>C</div>' +
|
||||
'</multiple-content-tags>',
|
||||
@ -129,9 +129,9 @@ export function main() {
|
||||
|
||||
it("should redistribute direct child viewcontainers when the light dom changes", inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'main',
|
||||
inline: '<multiple-content-tags>' +
|
||||
template: '<multiple-content-tags>' +
|
||||
'<div><div template="manual" class="left">A</div></div>' +
|
||||
'<div>B</div>' +
|
||||
'</multiple-content-tags>',
|
||||
@ -161,9 +161,9 @@ export function main() {
|
||||
|
||||
it("should redistribute when the light dom changes", inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'main',
|
||||
inline: '<multiple-content-tags>' +
|
||||
template: '<multiple-content-tags>' +
|
||||
'<div template="manual" class="left">A</div>' +
|
||||
'<div>B</div>' +
|
||||
'</multiple-content-tags>',
|
||||
@ -193,9 +193,9 @@ export function main() {
|
||||
|
||||
it("should support nested components", inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'main',
|
||||
inline: '<outer-with-indirect-nested>' +
|
||||
template: '<outer-with-indirect-nested>' +
|
||||
'<div>A</div>' +
|
||||
'<div>B</div>' +
|
||||
'</outer-with-indirect-nested>',
|
||||
@ -213,9 +213,9 @@ export function main() {
|
||||
|
||||
it("should support nesting with content being direct child of a nested component", inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'main',
|
||||
inline: '<outer>' +
|
||||
template: '<outer>' +
|
||||
'<div template="manual" class="left">A</div>' +
|
||||
'<div>B</div>' +
|
||||
'<div>C</div>' +
|
||||
@ -241,9 +241,9 @@ export function main() {
|
||||
|
||||
it('should redistribute when the shadow dom changes', inject([AsyncTestCompleter], (async) => {
|
||||
createRenderer({
|
||||
templates: [new Template({
|
||||
templates: [new ViewDefinition({
|
||||
componentId: 'main',
|
||||
inline: '<conditional-content>' +
|
||||
template: '<conditional-content>' +
|
||||
'<div class="left">A</div>' +
|
||||
'<div>B</div>' +
|
||||
'<div>C</div>' +
|
||||
@ -351,39 +351,39 @@ var autoViewportDirective = new DirectiveMetadata({
|
||||
});
|
||||
|
||||
var componentTemplates = [
|
||||
new Template({
|
||||
new ViewDefinition({
|
||||
componentId: 'simple',
|
||||
inline: 'SIMPLE(<content></content>)',
|
||||
template: 'SIMPLE(<content></content>)',
|
||||
directives: []
|
||||
}),
|
||||
new Template({
|
||||
new ViewDefinition({
|
||||
componentId: 'multiple-content-tags',
|
||||
inline: '(<content select=".left"></content>, <content></content>)',
|
||||
template: '(<content select=".left"></content>, <content></content>)',
|
||||
directives: []
|
||||
}),
|
||||
new Template({
|
||||
new ViewDefinition({
|
||||
componentId: 'outer-with-indirect-nested',
|
||||
inline: 'OUTER(<simple><div><content></content></div></simple>)',
|
||||
template: 'OUTER(<simple><div><content></content></div></simple>)',
|
||||
directives: [simple]
|
||||
}),
|
||||
new Template({
|
||||
new ViewDefinition({
|
||||
componentId: 'outer',
|
||||
inline: 'OUTER(<inner><content></content></inner>)',
|
||||
template: 'OUTER(<inner><content></content></inner>)',
|
||||
directives: [innerComponent]
|
||||
}),
|
||||
new Template({
|
||||
new ViewDefinition({
|
||||
componentId: 'inner',
|
||||
inline: 'INNER(<innerinner><content></content></innerinner>)',
|
||||
template: 'INNER(<innerinner><content></content></innerinner>)',
|
||||
directives: [innerInnerComponent]
|
||||
}),
|
||||
new Template({
|
||||
new ViewDefinition({
|
||||
componentId: 'innerinner',
|
||||
inline: 'INNERINNER(<content select=".left"></content>,<content></content>)',
|
||||
template: 'INNERINNER(<content select=".left"></content>,<content></content>)',
|
||||
directives: []
|
||||
}),
|
||||
new Template({
|
||||
new ViewDefinition({
|
||||
componentId: 'conditional-content',
|
||||
inline: '<div>(<div *auto="cond"><content select=".left"></content></div>, <content></content>)</div>',
|
||||
template: '<div>(<div *auto="cond"><content select=".left"></content></div>, <content></content>)</div>',
|
||||
directives: [autoViewportDirective]
|
||||
})
|
||||
];
|
||||
|
@ -17,7 +17,7 @@ var formatter = new DartFormatter();
|
||||
void allTests() {
|
||||
var reader = new TestAssetReader();
|
||||
|
||||
it('should generate a setter for a `bind` property in an annotation.',
|
||||
it('should generate a setter for a `properties` property in an annotation.',
|
||||
() async {
|
||||
var inputPath = 'bind_generator/basic_bind_files/bar.ng_deps.dart';
|
||||
var expected = formatter.format(
|
||||
|
@ -13,7 +13,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Decorator(
|
||||
selector: '[tool-tip]', bind: const {'text': 'tool-tip'})
|
||||
selector: '[tool-tip]', properties: const {'text': 'tool-tip'})
|
||||
]
|
||||
});
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Decorator(
|
||||
selector: '[tool-tip]', bind: const {'text': 'tool-tip'})
|
||||
selector: '[tool-tip]', properties: const {'text': 'tool-tip'})
|
||||
]
|
||||
})
|
||||
..registerSetters({'text': (o, String v) => o.text = v});
|
||||
|
@ -14,13 +14,13 @@ void initReflector(reflector) {
|
||||
'annotations': const [
|
||||
const Component(
|
||||
componentServices: const [SaladComponent],
|
||||
bind: const {'menu': 'menu'})
|
||||
properties: const {'menu': 'menu'})
|
||||
]
|
||||
})
|
||||
..registerType(SaladComponent, {
|
||||
'factory': () => new SaladComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [const Component(bind: const {'menu': 'menu'})]
|
||||
'annotations': const [const Component(properties: const {'menu': 'menu'})]
|
||||
})
|
||||
..registerSetters({'menu': (o, String v) => o.menu = v});
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ void initReflector(reflector) {
|
||||
'annotations': const [
|
||||
const Component(
|
||||
componentServices: const [SaladComponent],
|
||||
bind: const {'menu': 'menu'})
|
||||
properties: const {'menu': 'menu'})
|
||||
]
|
||||
})
|
||||
..registerType(SaladComponent, {
|
||||
'factory': () => new SaladComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [const Component(bind: const {'menu': 'menu'})]
|
||||
'annotations': const [const Component(properties: const {'menu': 'menu'})]
|
||||
});
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Component(
|
||||
selector: '[soup]', services: const [dep.DependencyComponent])
|
||||
selector: '[soup]', injectables: const [dep.DependencyComponent])
|
||||
]
|
||||
});
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Component(
|
||||
selector: '[soup]', services: const [dep.DependencyComponent])
|
||||
selector: '[soup]', injectables: const [dep.DependencyComponent])
|
||||
]
|
||||
});
|
||||
i0.initReflector(reflector);
|
||||
|
@ -91,8 +91,8 @@ void allTests() {
|
||||
inputs: {
|
||||
'a|web/index.dart': 'two_annotations_files/index.dart',
|
||||
'a|web/bar.dart': 'two_annotations_files/bar.dart',
|
||||
'angular2|lib/src/core/annotations/template.dart':
|
||||
'../../../lib/src/core/annotations/template.dart'
|
||||
'angular2|lib/src/core/annotations/view.dart':
|
||||
'../../../lib/src/core/annotations/view.dart'
|
||||
},
|
||||
outputs: {
|
||||
'a|web/bar.ng_deps.dart':
|
||||
|
@ -1,10 +1,10 @@
|
||||
library bar;
|
||||
|
||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
import 'package:angular2/src/core/annotations/template.dart';
|
||||
import 'package:angular2/src/core/annotations/view.dart';
|
||||
|
||||
@Component(selector: '[soup]')
|
||||
@Template(inline: 'Salad')
|
||||
@View(template: 'Salad')
|
||||
class MyComponent {
|
||||
MyComponent();
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ library bar.ng_deps.dart;
|
||||
|
||||
import 'bar.dart';
|
||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
import 'package:angular2/src/core/annotations/template.dart';
|
||||
import 'package:angular2/src/core/annotations/template.ng_deps.dart' as i0;
|
||||
import 'package:angular2/src/core/annotations/view.dart';
|
||||
import 'package:angular2/src/core/annotations/view.ng_deps.dart' as i0;
|
||||
import 'package:angular2/src/core/annotations/annotations.ng_deps.dart' as i1;
|
||||
|
||||
bool _visited = false;
|
||||
@ -16,7 +16,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Component(selector: '[soup]'),
|
||||
const Template(inline: 'Salad')
|
||||
const View(template: 'Salad')
|
||||
]
|
||||
});
|
||||
i0.initReflector(reflector);
|
||||
|
@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
show bootstrap, Component, Decorator, View, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void initReflector(reflector) {
|
||||
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const Template(inline: '{{greeting}}')
|
||||
const View(template: '{{greeting}}')
|
||||
]
|
||||
})
|
||||
..registerGetters({'greeting': (o) => o.greeting})
|
||||
|
@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
show bootstrap, Component, Decorator, View, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void initReflector(reflector) {
|
||||
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const Template(inline: '{{greeting}}')
|
||||
const View(template: '{{greeting}}')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
show bootstrap, Component, Decorator, View, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void initReflector(reflector) {
|
||||
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const Template(inline: '<button (click)=\"action()\">go</button>')
|
||||
const View(template: '<button (click)=\"action()\">go</button>')
|
||||
]
|
||||
})
|
||||
..registerMethods(
|
||||
|
@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
show bootstrap, Component, Decorator, View, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void initReflector(reflector) {
|
||||
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const Template(inline: '<button (click)=\"action()\">go</button>')
|
||||
const View(template: '<button (click)=\"action()\">go</button>')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ library examples.src.hello_world.index_common_dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
show bootstrap, Component, Decorator, View, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void initReflector(reflector) {
|
||||
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const Template(url: 'template.html')
|
||||
const View(templateUrl: 'template.html')
|
||||
]
|
||||
})
|
||||
..registerGetters({'greeting': (o) => o.greeting})
|
||||
|
@ -2,7 +2,7 @@ library examples.src.hello_world.index_common_dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
show bootstrap, Component, Decorator, View, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void initReflector(reflector) {
|
||||
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const Template(url: 'template.html')
|
||||
const View(templateUrl: 'template.html')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ library examples.src.hello_world.index_common_dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
show bootstrap, Component, Decorator, View, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void initReflector(reflector) {
|
||||
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const Template(url: 'template.html')
|
||||
const View(templateUrl: 'template.html')
|
||||
]
|
||||
})
|
||||
..registerMethods(
|
||||
|
@ -2,7 +2,7 @@ library examples.src.hello_world.index_common_dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
show bootstrap, Component, Decorator, View, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void initReflector(reflector) {
|
||||
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const Template(url: 'template.html')
|
||||
const View(templateUrl: 'template.html')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user