From 11ebe21d0dc8d82970153007e780800c87a76021 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 17 Jun 2021 18:06:33 +0100 Subject: [PATCH] test(compiler): check that the parser supports prematurely terminated interpolations (#42062) Such interpolations turned up during internal testing at Google, so this commit adds a test to prevent regressions. PR Close #42062 --- .../test/ml_parser/html_parser_spec.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/compiler/test/ml_parser/html_parser_spec.ts b/packages/compiler/test/ml_parser/html_parser_spec.ts index 45dcc1d957..a47d29ca3b 100644 --- a/packages/compiler/test/ml_parser/html_parser_spec.ts +++ b/packages/compiler/test/ml_parser/html_parser_spec.ts @@ -239,6 +239,23 @@ import {humanizeDom, humanizeDomSourceSpans, humanizeLineColumn, humanizeNodes} ]); expect(parsed.errors).toEqual([]); }); + + it('should treat prematurely terminated interpolation as text', () => { + const {errors, rootNodes} = + parser.parse('
x {{ expr }} y
', 'TestComp'); + expect(humanizeNodes(rootNodes, true)).toEqual([ + [ + html.Element, 'div', 0, '
x {{ expr }} y
', + '
', '
' + ], + [html.Element, 'span', 1, 'x {{ expr }} y', '', ''], + [html.Text, 'x {{ expr }', 2, ['x '], ['{{', ' expr }'], [''], 'x {{ expr }'], + [html.Comment, '', 2, '