From 83c70bd24d6783aeeedb8315f32a0fd90fefcfff Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Wed, 25 Nov 2020 19:39:20 +0100 Subject: [PATCH] fixup! fix(compiler): handle strings inside bindings that contain binding characters --- .../test/expression_parser/parser_spec.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/compiler/test/expression_parser/parser_spec.ts b/packages/compiler/test/expression_parser/parser_spec.ts index 52db2963805cc..30703a5e963c8 100644 --- a/packages/compiler/test/expression_parser/parser_spec.ts +++ b/packages/compiler/test/expression_parser/parser_spec.ts @@ -837,6 +837,31 @@ describe('parser', () => { expect(ast.expressions[0].name).toEqual('a'); }); + it('should parse interpolation inside quotes', () => { + const ast = parseInterpolation('"{{a}}"')!.ast as Interpolation; + expect(ast.strings).toEqual(['"', '"']); + expect(ast.expressions.length).toEqual(1); + expect(ast.expressions[0].name).toEqual('a'); + }); + + it('should parse interpolation with interpolation characters inside quotes', () => { + checkInterpolation('{{"{{a}}"}}', '{{ "{{a}}" }}'); + checkInterpolation('{{"{{"}}', '{{ "{{" }}'); + checkInterpolation('{{"}}"}}', '{{ "}}" }}'); + checkInterpolation('{{"{"}}', '{{ "{" }}'); + checkInterpolation('{{"}"}}', '{{ "}" }}'); + }); + + it('should parse interpolation with escaped quotes', () => { + checkInterpolation(`{{'It\\'s just Angular'}}`, `{{ "It's just Angular" }}`); + checkInterpolation(`{{'It\\'s {{ just Angular'}}`, `{{ "It's {{ just Angular" }}`); + checkInterpolation(`{{'It\\'s }} just Angular'}}`, `{{ "It's }} just Angular" }}`); + }); + + it('should not parse interpolation with mismatching quotes', () => { + expect(parseInterpolation(`{{ "{{a}}' }}`)).toBeNull(); + }); + it('should parse prefix/suffix with multiple interpolation', () => { const originalExp = 'before {{ a }} middle {{ b }} after'; const ast = parseInterpolation(originalExp)!.ast;