refactor(template): remove supporter deprecated var / # (#11084)

BREAKING CHANGES:

- `#` and `var` are not supported any more in expressions, use `let`,
- `var-<name>` could not be used any more on templates, use `let-<name>`,
- `var-<name>` could not be used any more to create a reference, use `ref-<name>`.
This commit is contained in:
Victor Berchet
2016-08-25 15:21:33 -07:00
committed by GitHub
parent ce08982f78
commit b867764b0d
4 changed files with 68 additions and 128 deletions

View File

@ -389,22 +389,6 @@ export function main() {
expect(bindings[0].expression.location).toEqual('location');
});
it('should support var notation with a deprecation warning', () => {
var bindings = createParser().parseTemplateBindings('var i', null);
expect(keyValues(bindings.templateBindings)).toEqual(['let i=\$implicit']);
expect(bindings.warnings).toEqual([
'"var" inside of expressions is deprecated. Use "let" instead!'
]);
});
it('should support # notation with a deprecation warning', () => {
var bindings = createParser().parseTemplateBindings('#i', null);
expect(keyValues(bindings.templateBindings)).toEqual(['let i=\$implicit']);
expect(bindings.warnings).toEqual([
'"#" inside of expressions is deprecated. Use "let" instead!'
]);
});
it('should support let notation', () => {
var bindings = parseTemplateBindings('let i');
expect(keyValues(bindings)).toEqual(['let i=\$implicit']);

View File

@ -838,15 +838,6 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
]))).toEqual([[ElementAst, 'div'], [ReferenceAst, 'a', null]]);
});
it('should parse references via var-... and report them as deprecated', () => {
expect(humanizeTplAst(parse('<div var-a>', [
]))).toEqual([[ElementAst, 'div'], [ReferenceAst, 'a', null]]);
expect(console.warnings).toEqual([[
'Template parse warnings:',
'"var-" on non <template> elements is deprecated. Use "ref-" instead! ("<div [ERROR ->]var-a>"): TestComp@0:5'
].join('\n')]);
});
it('should parse camel case references', () => {
expect(humanizeTplAst(parse('<div ref-someA>', [
]))).toEqual([[ElementAst, 'div'], [ReferenceAst, 'someA', null]]);
@ -960,15 +951,6 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
]))).toEqual([[EmbeddedTemplateAst], [VariableAst, 'a', 'b']]);
});
it('should parse variables via var-... and report them as deprecated', () => {
expect(humanizeTplAst(parse('<template var-a="b">', [
]))).toEqual([[EmbeddedTemplateAst], [VariableAst, 'a', 'b']]);
expect(console.warnings).toEqual([[
'Template parse warnings:',
'"var-" on <template> elements is deprecated. Use "let-" instead! ("<template [ERROR ->]var-a="b">"): TestComp@0:10'
].join('\n')]);
});
it('should not locate directives in variables', () => {
var dirA = CompileDirectiveMetadata.create({
selector: '[a]',
@ -1000,22 +982,9 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
]);
});
it('should parse variables via #... and report them as deprecated', () => {
expect(humanizeTplAst(parse('<div *ngIf="#a=b">', [
]))).toEqual([[EmbeddedTemplateAst], [VariableAst, 'a', 'b'], [ElementAst, 'div']]);
expect(console.warnings).toEqual([[
'Template parse warnings:',
'"#" inside of expressions is deprecated. Use "let" instead! ("<div [ERROR ->]*ngIf="#a=b">"): TestComp@0:5'
].join('\n')]);
});
it('should parse variables via var ... and report them as deprecated', () => {
expect(humanizeTplAst(parse('<div *ngIf="var a=b">', [
]))).toEqual([[EmbeddedTemplateAst], [VariableAst, 'a', 'b'], [ElementAst, 'div']]);
expect(console.warnings).toEqual([[
'Template parse warnings:',
'"var" inside of expressions is deprecated. Use "let" instead! ("<div [ERROR ->]*ngIf="var a=b">"): TestComp@0:5'
].join('\n')]);
it('should report an error on variables declared with #', () => {
expect(() => humanizeTplAst(parse('<div *ngIf="#a=b">', [])))
.toThrowError(/Parser Error: Unexpected token # at column 6/);
});
it('should parse variables via let ...', () => {