diff --git a/modules/@angular/compiler/src/expression_parser/parser.ts b/modules/@angular/compiler/src/expression_parser/parser.ts index b56d7df101..717f7b3045 100644 --- a/modules/@angular/compiler/src/expression_parser/parser.ts +++ b/modules/@angular/compiler/src/expression_parser/parser.ts @@ -237,16 +237,11 @@ export class _ParseAST { peekKeywordLet(): boolean { return this.next.isKeywordLet(); } - peekDeprecatedKeywordVar(): boolean { return this.next.isKeywordDeprecatedVar(); } - - peekDeprecatedOperatorHash(): boolean { return this.next.isOperator('#'); } - expectCharacter(code: number) { if (this.optionalCharacter(code)) return; this.error(`Missing expected ${StringWrapper.fromCharCode(code)}`); } - optionalOperator(op: string): boolean { if (this.next.isOperator(op)) { this.advance(); @@ -659,15 +654,7 @@ export class _ParseAST { let prefix: string = null; let warnings: string[] = []; while (this.index < this.tokens.length) { - var keyIsVar: boolean = this.peekKeywordLet(); - if (!keyIsVar && this.peekDeprecatedKeywordVar()) { - keyIsVar = true; - warnings.push(`"var" inside of expressions is deprecated. Use "let" instead!`); - } - if (!keyIsVar && this.peekDeprecatedOperatorHash()) { - keyIsVar = true; - warnings.push(`"#" inside of expressions is deprecated. Use "let" instead!`); - } + const keyIsVar: boolean = this.peekKeywordLet(); if (keyIsVar) { this.advance(); } @@ -688,12 +675,10 @@ export class _ParseAST { } else { name = '\$implicit'; } - } else if ( - this.next !== EOF && !this.peekKeywordLet() && !this.peekDeprecatedKeywordVar() && - !this.peekDeprecatedOperatorHash()) { + } else if (this.next !== EOF && !this.peekKeywordLet()) { const start = this.inputIndex; - var ast = this.parsePipe(); - var source = this.input.substring(start, this.inputIndex); + const ast = this.parsePipe(); + const source = this.input.substring(start, this.inputIndex); expression = new ASTWithSource(ast, source, this.location, this.errors); } bindings.push(new TemplateBinding(key, keyIsVar, name, expression)); @@ -723,7 +708,7 @@ export class _ParseAST { // of the '(' begins an '(' ')' production). The recovery points of grouping symbols // must be conditional as they must be skipped if none of the calling productions are not // expecting the closing token else we will never make progress in the case of an - // extrainious group closing symbol (such as a stray ')'). This is not the case for ';' because + // extraneous group closing symbol (such as a stray ')'). This is not the case for ';' because // parseChain() is always the root production and it expects a ';'. // If a production expects one of these token it increments the corresponding nesting count, diff --git a/modules/@angular/compiler/src/template_parser/template_parser.ts b/modules/@angular/compiler/src/template_parser/template_parser.ts index e87bb2769b..bb30c71dd9 100644 --- a/modules/@angular/compiler/src/template_parser/template_parser.ts +++ b/modules/@angular/compiler/src/template_parser/template_parser.ts @@ -34,18 +34,28 @@ import {PreparsedElementType, preparseElement} from './template_preparser'; // Group 1 = "bind-" -// Group 2 = "var-" -// Group 3 = "let-" -// Group 4 = "ref-/#" -// Group 5 = "on-" -// Group 6 = "bindon-" -// Group 7 = "@" -// Group 8 = the identifier after "bind-", "var-/#", or "on-" -// Group 9 = identifier inside [()] -// Group 10 = identifier inside [] -// Group 11 = identifier inside () +// Group 2 = "let-" +// Group 3 = "ref-/#" +// Group 4 = "on-" +// Group 5 = "bindon-" +// Group 6 = "@" +// Group 7 = the identifier after "bind-", "let-", "ref-/#", "on-", "bindon-" or "@" +// Group 8 = identifier inside [()] +// Group 9 = identifier inside [] +// Group 10 = identifier inside () const BIND_NAME_REGEXP = - /^(?:(?:(?:(bind-)|(var-)|(let-)|(ref-|#)|(on-)|(bindon-)|(@))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/; + /^(?:(?:(?:(bind-)|(let-)|(ref-|#)|(on-)|(bindon-)|(@))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/; + +const KW_BIND_IDX = 1; +const KW_LET_IDX = 2; +const KW_REF_IDX = 3; +const KW_ON_IDX = 4; +const KW_BINDON_IDX = 5; +const KW_AT_IDX = 6; +const IDENT_KW_IDX = 7; +const IDENT_BANANA_BOX_IDX = 8; +const IDENT_PROPERTY_IDX = 9; +const IDENT_EVENT_IDX = 10; const ANIMATE_PROP_PREFIX = 'animate-'; const TEMPLATE_ELEMENT = 'template'; @@ -490,90 +500,82 @@ class TemplateParseVisitor implements html.Visitor { targetProps: BoundElementOrDirectiveProperty[], targetAnimationProps: BoundElementPropertyAst[], targetEvents: BoundEventAst[], targetRefs: ElementOrDirectiveRef[], targetVars: VariableAst[]): boolean { - const attrName = this._normalizeAttributeName(attr.name); - const attrValue = attr.value; - const bindParts = attrName.match(BIND_NAME_REGEXP); + const name = this._normalizeAttributeName(attr.name); + const value = attr.value; + const srcSpan = attr.sourceSpan; + + const bindParts = name.match(BIND_NAME_REGEXP); let hasBinding = false; + if (bindParts !== null) { hasBinding = true; - if (isPresent(bindParts[1])) { // match: bind-prop + if (isPresent(bindParts[KW_BIND_IDX])) { this._parsePropertyOrAnimation( - bindParts[8], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps, + bindParts[IDENT_KW_IDX], value, srcSpan, targetMatchableAttrs, targetProps, targetAnimationProps); - } else if (isPresent(bindParts[2])) { // match: var-name / var-name="iden" - const identifier = bindParts[8]; + } else if (bindParts[KW_LET_IDX]) { if (isTemplateElement) { - this._reportError( - `"var-" on