Skip to content

Commit fa73293

Browse files
committed
Fix: v-on directive allows object-expressions (fixes #30)
1 parent 0a5d568 commit fa73293

File tree

5 files changed

+1023
-7
lines changed

5 files changed

+1023
-7
lines changed

Diff for: src/template/index.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ function insertError(
256256
* @param globalLocationCalculator The location calculator to adjust the locations of nodes.
257257
* @param node The attribute node to replace. This function modifies this node directly.
258258
* @param tagName The name of this tag.
259-
* @param directiveName The name of this directive.
259+
* @param directiveKey The key of this directive.
260260
*/
261261
function parseAttributeValue(
262262
code: string,
263263
parserOptions: any,
264264
globalLocationCalculator: LocationCalculator,
265265
node: VLiteral,
266266
tagName: string,
267-
directiveName: string,
267+
directiveKey: VDirectiveKey,
268268
): ExpressionParseResult {
269269
const firstChar = code[node.range[0]]
270270
const quoted = firstChar === '"' || firstChar === "'"
@@ -281,21 +281,21 @@ function parseAttributeValue(
281281
variables: [],
282282
references: [],
283283
}
284-
} else if (directiveName === "for") {
284+
} else if (directiveKey.name === "for") {
285285
result = parseVForExpression(
286286
node.value,
287287
locationCalculator,
288288
parserOptions,
289289
)
290-
} else if (directiveName === "on") {
290+
} else if (directiveKey.name === "on" && directiveKey.argument != null) {
291291
result = parseVOnExpression(
292292
node.value,
293293
locationCalculator,
294294
parserOptions,
295295
)
296296
} else if (
297-
directiveName === "slot-scope" ||
298-
(tagName === "template" && directiveName === "scope")
297+
directiveKey.name === "slot-scope" ||
298+
(tagName === "template" && directiveKey.name === "scope")
299299
) {
300300
result = parseSlotScopeExpression(
301301
node.value,
@@ -398,7 +398,7 @@ export function convertToDirective(
398398
locationCalculator,
399399
node.value,
400400
node.parent.parent.name,
401-
directive.key.name,
401+
directive.key,
402402
)
403403

404404
directive.value = {

0 commit comments

Comments
 (0)