diff --git a/packages/compiler/src/chars.ts b/packages/compiler/src/chars.ts index 5ba122d803..4bb0a4ec4a 100644 --- a/packages/compiler/src/chars.ts +++ b/packages/compiler/src/chars.ts @@ -98,3 +98,7 @@ export function isNewLine(code: number): boolean { export function isOctalDigit(code: number): boolean { return $0 <= code && code <= $7; } + +export function isQuote(code: number): boolean { + return code === $SQ || code === $DQ || code === $BT; +} diff --git a/packages/compiler/src/expression_parser/lexer.ts b/packages/compiler/src/expression_parser/lexer.ts index 39372a4b07..103e32f78c 100644 --- a/packages/compiler/src/expression_parser/lexer.ts +++ b/packages/compiler/src/expression_parser/lexer.ts @@ -436,10 +436,6 @@ function isExponentSign(code: number): boolean { return code == chars.$MINUS || code == chars.$PLUS; } -export function isQuote(code: number): boolean { - return code === chars.$SQ || code === chars.$DQ || code === chars.$BT; -} - function unescape(code: number): number { switch (code) { case chars.$n: diff --git a/packages/compiler/src/expression_parser/parser.ts b/packages/compiler/src/expression_parser/parser.ts index 7fc84c14ae..1c0f105794 100644 --- a/packages/compiler/src/expression_parser/parser.ts +++ b/packages/compiler/src/expression_parser/parser.ts @@ -10,7 +10,7 @@ import * as chars from '../chars'; import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../ml_parser/interpolation_config'; import {AbsoluteSourceSpan, AST, AstVisitor, ASTWithSource, Binary, BindingPipe, Chain, Conditional, EmptyExpr, ExpressionBinding, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralMapKey, LiteralPrimitive, MethodCall, NonNullAssert, ParserError, ParseSpan, PrefixNot, PropertyRead, PropertyWrite, Quote, RecursiveAstVisitor, SafeKeyedRead, SafeMethodCall, SafePropertyRead, TemplateBinding, TemplateBindingIdentifier, ThisReceiver, Unary, VariableBinding} from './ast'; -import {EOF, isIdentifier, isQuote, Lexer, Token, TokenType} from './lexer'; +import {EOF, isIdentifier, Lexer, Token, TokenType} from './lexer'; export interface InterpolationPiece { text: string; @@ -291,7 +291,7 @@ export class Parser { if (outerQuote === char) { outerQuote = null; - } else if (outerQuote == null && isQuote(char)) { + } else if (outerQuote == null && chars.isQuote(char)) { outerQuote = char; } } @@ -355,7 +355,7 @@ export class Parser { const char = input[i]; // Skip the characters inside quotes. Note that we only care about the outer-most // quotes matching up and we need to account for escape characters. - if (isQuote(input.charCodeAt(i)) && (currentQuote === null || currentQuote === char) && + if (chars.isQuote(input.charCodeAt(i)) && (currentQuote === null || currentQuote === char) && escapeCount % 2 === 0) { currentQuote = currentQuote === null ? char : null; } else if (currentQuote === null) {