Skip to content

Commit

Permalink
fixup! fix(compiler): handle strings inside bindings that contain bin…
Browse files Browse the repository at this point in the history
…ding characters
  • Loading branch information
crisbeto committed Nov 28, 2020
1 parent c96f65f commit 674d300
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/compiler/test/expression_parser/parser_spec.ts
Expand Up @@ -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;
Expand Down

0 comments on commit 674d300

Please sign in to comment.