From 9b0e10e9a749791be66c2330a21bd7fb5253f8ad Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Mon, 21 Dec 2015 11:32:23 -0500 Subject: [PATCH] fix(compiler): fix interpolation regexp - Fix the interpolation regexp to match newline characters (i.e. `\n` and `\r`) Closes #6056 --- modules/angular2/src/core/change_detection/parser/parser.ts | 2 +- .../angular2/test/core/change_detection/parser/parser_spec.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/core/change_detection/parser/parser.ts b/modules/angular2/src/core/change_detection/parser/parser.ts index 27a1c8cb67..541890177a 100644 --- a/modules/angular2/src/core/change_detection/parser/parser.ts +++ b/modules/angular2/src/core/change_detection/parser/parser.ts @@ -49,7 +49,7 @@ import { var _implicitReceiver = new ImplicitReceiver(); // TODO(tbosch): Cannot make this const/final right now because of the transpiler... -var INTERPOLATION_REGEXP = /\{\{(.*?)\}\}/g; +var INTERPOLATION_REGEXP = /\{\{([\s\S]*?)\}\}/g; class ParseException extends BaseException { constructor(message: string, input: string, errLocation: string, ctxLocation?: any) { diff --git a/modules/angular2/test/core/change_detection/parser/parser_spec.ts b/modules/angular2/test/core/change_detection/parser/parser_spec.ts index c349f61757..1970cdc944 100644 --- a/modules/angular2/test/core/change_detection/parser/parser_spec.ts +++ b/modules/angular2/test/core/change_detection/parser/parser_spec.ts @@ -421,6 +421,10 @@ export function main() { it('should parse conditional expression', () => { checkInterpolation('{{ a < b ? a : b }}'); }); + + it('should parse expression with newline characters', () => { + checkInterpolation(`{{ 'foo' +\n 'bar' +\r 'baz' }}`, `{{ "foo" + "bar" + "baz" }}`); + }); }); describe("parseSimpleBinding", () => {