Преглед на файлове

refactor(compiler-vapor): don't convert event name

三咲智子 Kevin Deng преди 2 години
родител
ревизия
c70661c8a3

+ 0 - 12
packages/compiler-vapor/__tests__/transforms/__snapshots__/vOn.spec.ts.snap

@@ -1,17 +1,5 @@
 // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
 
-exports[`v-on > case conversion for kebab-case events 1`] = `
-"import { children as _children, on as _on, template as _template } from 'vue/vapor';
-const t0 = _template("<div></div>")
-
-export function render(_ctx) {
-  const n0 = t0()
-  const { 0: [n1],} = _children(n0)
-  _on(n1, "fooBar", () => _ctx.onMount)
-  return n0
-}"
-`;
-
 exports[`v-on > complex member expression w/ prefixIdentifiers: true 1`] = `
 "import { children as _children, on as _on, template as _template } from 'vue/vapor';
 const t0 = _template("<div></div>")

+ 0 - 30
packages/compiler-vapor/__tests__/transforms/vOn.spec.ts

@@ -410,36 +410,6 @@ describe('v-on', () => {
     expect(onError).not.toHaveBeenCalled()
   })
 
-  test('case conversion for kebab-case events', () => {
-    const { ir, code, helpers, vaporHelpers } = compileWithVOn(
-      `<div v-on:foo-bar="onMount"/>`,
-    )
-
-    expect(vaporHelpers).contains('on')
-    expect(helpers.size).toBe(0)
-    expect(ir.effect).toEqual([])
-
-    expect(ir.operation).toMatchObject([
-      {
-        type: IRNodeTypes.SET_EVENT,
-        element: 1,
-        key: {
-          type: NodeTypes.SIMPLE_EXPRESSION,
-          content: 'fooBar',
-          isStatic: true,
-        },
-        value: {
-          type: NodeTypes.SIMPLE_EXPRESSION,
-          content: 'onMount',
-          isStatic: false,
-        },
-      },
-    ])
-
-    expect(code).matchSnapshot()
-    expect(code).contains('fooBar')
-  })
-
   test('should support multiple modifiers and event options w/ prefixIdentifiers: true', () => {
     const { code, ir, vaporHelpers } = compileWithVOn(
       `<div @click.stop.prevent.capture.once="test"/>`,

+ 2 - 12
packages/compiler-vapor/src/transforms/vOn.ts

@@ -1,12 +1,8 @@
-import {
-  ElementTypes,
-  ErrorCodes,
-  createCompilerError,
-} from '@vue/compiler-dom'
+import { ErrorCodes, createCompilerError } from '@vue/compiler-dom'
 import type { DirectiveTransform } from '../transform'
 import { IRNodeTypes, type KeyOverride, type SetEventIRNode } from '../ir'
 import { resolveModifiers } from '@vue/compiler-dom'
-import { camelize, extend } from '@vue/shared'
+import { extend } from '@vue/shared'
 import { resolveExpression } from '../utils'
 
 export const transformVOn: DirectiveTransform = (dir, node, context) => {
@@ -23,12 +19,6 @@ export const transformVOn: DirectiveTransform = (dir, node, context) => {
   }
 
   arg = resolveExpression(arg)
-  if (arg.isStatic) {
-    if (node.tagType !== ElementTypes.ELEMENT || !/[A-Z]/.test(arg.content)) {
-      arg.content = camelize(arg.content)
-    }
-  }
-
   const { keyModifiers, nonKeyModifiers, eventOptionModifiers } =
     resolveModifiers(
       arg.isStatic ? `on${arg.content}` : arg,