Skip to content

Commit

Permalink
Fix: v-on directive allows object-expressions (fixes #30)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jul 20, 2018
1 parent 0a5d568 commit fa73293
Show file tree
Hide file tree
Showing 5 changed files with 1,023 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ function insertError(
* @param globalLocationCalculator The location calculator to adjust the locations of nodes.
* @param node The attribute node to replace. This function modifies this node directly.
* @param tagName The name of this tag.
* @param directiveName The name of this directive.
* @param directiveKey The key of this directive.
*/
function parseAttributeValue(
code: string,
parserOptions: any,
globalLocationCalculator: LocationCalculator,
node: VLiteral,
tagName: string,
directiveName: string,
directiveKey: VDirectiveKey,
): ExpressionParseResult {
const firstChar = code[node.range[0]]
const quoted = firstChar === '"' || firstChar === "'"
Expand All @@ -281,21 +281,21 @@ function parseAttributeValue(
variables: [],
references: [],
}
} else if (directiveName === "for") {
} else if (directiveKey.name === "for") {
result = parseVForExpression(
node.value,
locationCalculator,
parserOptions,
)
} else if (directiveName === "on") {
} else if (directiveKey.name === "on" && directiveKey.argument != null) {
result = parseVOnExpression(
node.value,
locationCalculator,
parserOptions,
)
} else if (
directiveName === "slot-scope" ||
(tagName === "template" && directiveName === "scope")
directiveKey.name === "slot-scope" ||
(tagName === "template" && directiveKey.name === "scope")
) {
result = parseSlotScopeExpression(
node.value,
Expand Down Expand Up @@ -398,7 +398,7 @@ export function convertToDirective(
locationCalculator,
node.value,
node.parent.parent.name,
directive.key.name,
directive.key,
)

directive.value = {
Expand Down

0 comments on commit fa73293

Please sign in to comment.