X Tutup
Skip to content

Commit 9b0e10e

Browse files
wesleychoalexeagle
authored andcommitted
fix(compiler): fix interpolation regexp
- Fix the interpolation regexp to match newline characters (i.e. `\n` and `\r`) Closes #6056
1 parent 995a9e0 commit 9b0e10e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

modules/angular2/src/core/change_detection/parser/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import {
4949

5050
var _implicitReceiver = new ImplicitReceiver();
5151
// TODO(tbosch): Cannot make this const/final right now because of the transpiler...
52-
var INTERPOLATION_REGEXP = /\{\{(.*?)\}\}/g;
52+
var INTERPOLATION_REGEXP = /\{\{([\s\S]*?)\}\}/g;
5353

5454
class ParseException extends BaseException {
5555
constructor(message: string, input: string, errLocation: string, ctxLocation?: any) {

modules/angular2/test/core/change_detection/parser/parser_spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ export function main() {
421421

422422
it('should parse conditional expression',
423423
() => { checkInterpolation('{{ a < b ? a : b }}'); });
424+
425+
it('should parse expression with newline characters', () => {
426+
checkInterpolation(`{{ 'foo' +\n 'bar' +\r 'baz' }}`, `{{ "foo" + "bar" + "baz" }}`);
427+
});
424428
});
425429

426430
describe("parseSimpleBinding", () => {

0 commit comments

Comments
 (0)
X Tutup