'],
+ [BoundDirectivePropertyAst, 'aProp', '(foo | bar)', '[a-prop]="foo | bar"']
+ ]);
+ });
+
+ });
});
}
-export function humanizeTemplateAsts(templateAsts: TemplateAst[]): any[] {
- var humanizer = new TemplateHumanizer();
+function humanizeTplAst(templateAsts: TemplateAst[]): any[] {
+ var humanizer = new TemplateHumanizer(false);
+ templateVisitAll(humanizer, templateAsts);
+ return humanizer.result;
+}
+
+function humanizeTplAstSourceSpans(templateAsts: TemplateAst[]): any[] {
+ var humanizer = new TemplateHumanizer(true);
templateVisitAll(humanizer, templateAsts);
return humanizer.result;
}
class TemplateHumanizer implements TemplateAstVisitor {
result: any[] = [];
+
+ constructor(private includeSourceSpan: boolean){};
+
visitNgContent(ast: NgContentAst, context: any): any {
- this.result.push([NgContentAst]);
+ var res = [NgContentAst];
+ this.result.push(this._appendContext(ast, res));
return null;
}
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
- this.result.push([EmbeddedTemplateAst]);
+ var res = [EmbeddedTemplateAst];
+ this.result.push(this._appendContext(ast, res));
templateVisitAll(this, ast.attrs);
templateVisitAll(this, ast.outputs);
templateVisitAll(this, ast.vars);
@@ -778,7 +959,8 @@ class TemplateHumanizer implements TemplateAstVisitor {
return null;
}
visitElement(ast: ElementAst, context: any): any {
- this.result.push([ElementAst, ast.name]);
+ var res = [ElementAst, ast.name];
+ this.result.push(this._appendContext(ast, res));
templateVisitAll(this, ast.attrs);
templateVisitAll(this, ast.inputs);
templateVisitAll(this, ast.outputs);
@@ -788,38 +970,44 @@ class TemplateHumanizer implements TemplateAstVisitor {
return null;
}
visitVariable(ast: VariableAst, context: any): any {
- this.result.push([VariableAst, ast.name, ast.value]);
+ var res = [VariableAst, ast.name, ast.value];
+ this.result.push(this._appendContext(ast, res));
return null;
}
visitEvent(ast: BoundEventAst, context: any): any {
- this.result.push(
- [BoundEventAst, ast.name, ast.target, expressionUnparser.unparse(ast.handler)]);
+ var res = [BoundEventAst, ast.name, ast.target, expressionUnparser.unparse(ast.handler)];
+ this.result.push(this._appendContext(ast, res));
return null;
}
visitElementProperty(ast: BoundElementPropertyAst, context: any): any {
- this.result.push([
+ var res = [
BoundElementPropertyAst,
ast.type,
ast.name,
expressionUnparser.unparse(ast.value),
ast.unit
- ]);
+ ];
+ this.result.push(this._appendContext(ast, res));
return null;
}
visitAttr(ast: AttrAst, context: any): any {
- this.result.push([AttrAst, ast.name, ast.value]);
+ var res = [AttrAst, ast.name, ast.value];
+ this.result.push(this._appendContext(ast, res));
return null;
}
visitBoundText(ast: BoundTextAst, context: any): any {
- this.result.push([BoundTextAst, expressionUnparser.unparse(ast.value)]);
+ var res = [BoundTextAst, expressionUnparser.unparse(ast.value)];
+ this.result.push(this._appendContext(ast, res));
return null;
}
visitText(ast: TextAst, context: any): any {
- this.result.push([TextAst, ast.value]);
+ var res = [TextAst, ast.value];
+ this.result.push(this._appendContext(ast, res));
return null;
}
visitDirective(ast: DirectiveAst, context: any): any {
- this.result.push([DirectiveAst, ast.directive]);
+ var res = [DirectiveAst, ast.directive];
+ this.result.push(this._appendContext(ast, res));
templateVisitAll(this, ast.inputs);
templateVisitAll(this, ast.hostProperties);
templateVisitAll(this, ast.hostEvents);
@@ -827,10 +1015,16 @@ class TemplateHumanizer implements TemplateAstVisitor {
return null;
}
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any {
- this.result.push(
- [BoundDirectivePropertyAst, ast.directiveName, expressionUnparser.unparse(ast.value)]);
+ var res = [BoundDirectivePropertyAst, ast.directiveName, expressionUnparser.unparse(ast.value)];
+ this.result.push(this._appendContext(ast, res));
return null;
}
+
+ private _appendContext(ast: TemplateAst, input: any[]): any[] {
+ if (!this.includeSourceSpan) return input;
+ input.push(ast.sourceSpan.toString());
+ return input;
+ }
}
function sourceInfo(ast: TemplateAst): string {
diff --git a/modules/angular2/test/core/linker/integration_spec.ts b/modules/angular2/test/core/linker/integration_spec.ts
index 4dbffecbf2..da647f2a43 100644
--- a/modules/angular2/test/core/linker/integration_spec.ts
+++ b/modules/angular2/test/core/linker/integration_spec.ts
@@ -9,7 +9,7 @@ import {
expect,
iit,
inject,
- beforeEachBindings,
+ beforeEachProviders,
it,
xit,
containsRegexp,
@@ -99,7 +99,7 @@ const ANCHOR_ELEMENT = CONST_EXPR(new OpaqueToken('AnchorElement'));
export function main() {
describe('integration tests', function() {
- beforeEachBindings(() => [provide(ANCHOR_ELEMENT, {useValue: el('
')})]);
+ beforeEachProviders(() => [provide(ANCHOR_ELEMENT, {useValue: el('
')})]);
describe('react to record changes', function() {
it('should consume text node changes',
@@ -536,21 +536,21 @@ export function main() {
})}));
it('should assign a directive to a var-',
- inject([TestComponentBuilder, AsyncTestCompleter],
- (tcb: TestComponentBuilder, async) => {
- tcb.overrideView(MyComp, new ViewMetadata({
- template: '
',
- directives: [ExportDir]
- }))
+ inject(
+ [TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
+ tcb.overrideView(MyComp, new ViewMetadata({
+ template: '
',
+ directives: [ExportDir]
+ }))
- .createAsync(MyComp)
- .then((fixture) => {
- expect(fixture.debugElement.componentViewChildren[0].getLocal('localdir'))
- .toBeAnInstanceOf(ExportDir);
+ .createAsync(MyComp)
+ .then((fixture) => {
+ expect(fixture.debugElement.componentViewChildren[0].getLocal('localdir'))
+ .toBeAnInstanceOf(ExportDir);
- async.done();
- });
- }));
+ async.done();
+ });
+ }));
it('should make the assigned component accessible in property bindings',
inject(
@@ -616,9 +616,9 @@ export function main() {
it('should assign the element instance to a user-defined variable',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
- tcb.overrideView(MyComp,
- new ViewMetadata(
- {template: '
Hello
'}))
+ tcb.overrideView(MyComp, new ViewMetadata({
+ template: '
'
+ }))
.createAsync(MyComp)
.then((fixture) => {
@@ -1514,7 +1514,7 @@ export function main() {
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
expect(e.message).toEqual(
- `Template parse errors:\nCan't bind to 'unknown' since it isn't a known native property in MyComp > div:nth-child(0)[unknown={{ctxProp}}]`);
+ `Template parse errors:\nCan't bind to 'unknown' since it isn't a known native property ("
]unknown="{{ctxProp}}">
"): MyComp@0:5`);
async.done();
return null;
});
@@ -1572,7 +1572,7 @@ export function main() {
});
describe('logging property updates', () => {
- beforeEachBindings(() => [
+ beforeEachProviders(() => [
provide(ChangeDetectorGenConfig,
{useValue: new ChangeDetectorGenConfig(true, true, false)})
]);
diff --git a/modules/angular2/test/core/linker/projection_integration_spec.ts b/modules/angular2/test/core/linker/projection_integration_spec.ts
index 731e68d982..e30dc0f036 100644
--- a/modules/angular2/test/core/linker/projection_integration_spec.ts
+++ b/modules/angular2/test/core/linker/projection_integration_spec.ts
@@ -569,7 +569,7 @@ class Empty {
@Component({selector: 'multiple-content-tags'})
@View({
- template: '(
,
)',
+ template: '(
,
)',
directives: []
})
class MultipleContentTagsComponent {
diff --git a/modules/playground/src/zippy_component/zippy.html b/modules/playground/src/zippy_component/zippy.html
index 418bdc9ab8..4d5c36fb45 100644
--- a/modules/playground/src/zippy_component/zippy.html
+++ b/modules/playground/src/zippy_component/zippy.html
@@ -1,6 +1,6 @@
- {{ visible ? '▾' : '▸' }} {{title}}
+ {{ visible ? '▾' : '▸' }} {{title}}