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
@@ -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: []
})]
});
+9 -9
View File
@@ -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]
})
];