Skip to content

Commit

Permalink
fix parsing of expressions wrapped in parentheses (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Apr 30, 2017
1 parent 8e87c68 commit a5dce59
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parse/read/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function readExpression ( parser ) {
parser.index = start;

try {
const node = parseExpressionAt( parser.template, parser.index );
const node = parseExpressionAt( parser.template, parser.index, { preserveParens: true } );
parser.index = node.end;

return node;
Expand Down
16 changes: 16 additions & 0 deletions test/runtime/samples/paren-wrapped-expressions/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
data: {
a: 'foo',
b: true,
c: [ 1, 2, 3 ],
},

html: `
<span>foo</span>
<span class="foo"></span>
<span>true</span>
<span>1</span>
<span>2</span>
<span>3</span>
`
};
8 changes: 8 additions & 0 deletions test/runtime/samples/paren-wrapped-expressions/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<span>{{ (a) }}</span>
<span class='{{ (a) }}'></span>
{{#if (b) }}
<span>true</span>
{{/if}}
{{#each (c) as x}}
<span>{{x}}</span>
{{/each}}

0 comments on commit a5dce59

Please sign in to comment.