Skip to content

Commit

Permalink
fix(language-core): fix nameless event expression formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed May 4, 2024
1 parent 4d8529b commit 7e40bca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const plugin: VueLanguagePlugin = ctx => {
prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
&& prop.exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY // style='z-index: 2' will compile to {'z-index':'2'}
) {
if (prop.name === 'on') {
if (prop.name === 'on' && prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
const ast = createTsAst(ctx.modules.typescript, prop.exp, prop.exp.content);
addFormatCodes(
prop.exp.content,
Expand Down
14 changes: 14 additions & 0 deletions packages/language-service/tests/format/4333.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineFormatTest } from '../utils/format';

defineFormatTest({
title: '#' + __filename.split('.')[0],
languageId: 'vue',
input: `
<template>
<div v-on="{ click: onItemInteraction, keydown: onItemInteraction }"></div>
</template>
`.trim(),
settings: {
'typescript.format.semicolons': 'insert',
}
});

0 comments on commit 7e40bca

Please sign in to comment.