Skip to content

Commit

Permalink
🐛 filters are allowed only on v-bind or mustache (fixes #34)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Dec 5, 2018
1 parent 0248739 commit 309cf52
Show file tree
Hide file tree
Showing 6 changed files with 793 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,13 @@ export function parseExpression(
code: string,
locationCalculator: LocationCalculator,
parserOptions: any,
allowEmpty = false,
{ allowEmpty = false, allowFilters = false } = {},
): ExpressionParseResult<ESLintExpression | VFilterSequenceExpression> {
debug('[script] parse expression: "%s"', code)

const [mainCode, ...filterCodes] = splitFilters(code)
const [mainCode, ...filterCodes] = allowFilters
? splitFilters(code)
: [code]
if (filterCodes.length === 0) {
return parseExpressionBody(
code,
Expand Down
9 changes: 8 additions & 1 deletion src/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ function parseAttributeValue(
locationCalculator,
parserOptions,
)
} else if (directiveKey.name === "bind") {
result = parseExpression(
node.value,
locationCalculator,
parserOptions,
{ allowFilters: true },
)
} else {
result = parseExpression(node.value, locationCalculator, parserOptions)
}
Expand Down Expand Up @@ -483,7 +490,7 @@ export function processMustache(
mustache.value,
locationCalculator,
parserOptions,
true,
{ allowEmpty: true, allowFilters: true },
)

node.expression = ret.expression || null
Expand Down
Loading

0 comments on commit 309cf52

Please sign in to comment.