chore: update

This commit is contained in:
linzhe141 2025-03-18 14:12:57 +08:00
parent 60a554cd86
commit d2d2e3d08d
8 changed files with 32 additions and 22 deletions

View File

@ -63,9 +63,6 @@ export const CAPITALIZE: unique symbol = Symbol(__DEV__ ? `capitalize` : ``)
export const TO_HANDLER_KEY: unique symbol = Symbol(
__DEV__ ? `toHandlerKey` : ``,
)
export const CHECK_DYNAMIC_EVENT: unique symbol = Symbol(
__DEV__ ? `checkDynamicEvent` : ``,
)
export const SET_BLOCK_TRACKING: unique symbol = Symbol(
__DEV__ ? `setBlockTracking` : ``,
)
@ -118,7 +115,6 @@ export const helperNameMap: Record<symbol, string> = {
[CAMELIZE]: `camelize`,
[CAPITALIZE]: `capitalize`,
[TO_HANDLER_KEY]: `toHandlerKey`,
[CHECK_DYNAMIC_EVENT]: `checkDynamicEvent`,
[SET_BLOCK_TRACKING]: `setBlockTracking`,
[PUSH_SCOPE_ID]: `pushScopeId`,
[POP_SCOPE_ID]: `popScopeId`,

View File

@ -5,12 +5,12 @@ exports[`compiler-dom: transform v-on > should wrap both for dynamic key event w
return function render(_ctx, _cache) {
with (_ctx) {
const { toHandlerKey: _toHandlerKey, checkDynamicEvent: _checkDynamicEvent, createElementVNode: _createElementVNode, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
const { toHandlerKey: _toHandlerKey, withDynamicEventModifiers: _withDynamicEventModifiers, createElementVNode: _createElementVNode, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
return (_openBlock(), _createElementBlock(_Fragment, null, [
_createElementVNode("div", { [_checkDynamicEvent(_toHandlerKey(e),"Once")]: test }, null, 16 /* FULL_PROPS */),
_createElementVNode("div", { [_checkDynamicEvent(_toHandlerKey(e),"Passive")]: test }, null, 16 /* FULL_PROPS */),
_createElementVNode("div", { [_checkDynamicEvent(_toHandlerKey(e),"Capture")]: test }, null, 16 /* FULL_PROPS */)
_createElementVNode("div", { [_withDynamicEventModifiers(_toHandlerKey(e), "Once")]: test }, null, 16 /* FULL_PROPS */),
_createElementVNode("div", { [_withDynamicEventModifiers(_toHandlerKey(e), "Passive")]: test }, null, 16 /* FULL_PROPS */),
_createElementVNode("div", { [_withDynamicEventModifiers(_toHandlerKey(e), "Capture")]: test }, null, 16 /* FULL_PROPS */)
], 64 /* STABLE_FRAGMENT */))
}
}"

View File

@ -18,6 +18,9 @@ export const V_ON_WITH_MODIFIERS: unique symbol = Symbol(
export const V_ON_WITH_KEYS: unique symbol = Symbol(
__DEV__ ? `vOnKeysGuard` : ``,
)
export const V_ON_WITH_DYNAMIC_EVENT_MODIFIERS: unique symbol = Symbol(
__DEV__ ? `vOnDynamicEventModifiers` : ``,
)
export const V_SHOW: unique symbol = Symbol(__DEV__ ? `vShow` : ``)
@ -34,6 +37,7 @@ registerRuntimeHelpers({
[V_MODEL_DYNAMIC]: `vModelDynamic`,
[V_ON_WITH_MODIFIERS]: `withModifiers`,
[V_ON_WITH_KEYS]: `withKeys`,
[V_ON_WITH_DYNAMIC_EVENT_MODIFIERS]: `withDynamicEventModifiers`,
[V_SHOW]: `vShow`,
[TRANSITION]: `Transition`,
[TRANSITION_GROUP]: `TransitionGroup`,

View File

@ -1,5 +1,4 @@
import {
CHECK_DYNAMIC_EVENT,
CompilerDeprecationTypes,
type DirectiveTransform,
type ExpressionNode,
@ -15,7 +14,11 @@ import {
createSimpleExpression,
isStaticExp,
} from '@vue/compiler-core'
import { V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS } from '../runtimeHelpers'
import {
V_ON_WITH_DYNAMIC_EVENT_MODIFIERS,
V_ON_WITH_KEYS,
V_ON_WITH_MODIFIERS,
} from '../runtimeHelpers'
import { capitalize, makeMap } from '@vue/shared'
const isEventOptionModifier = /*@__PURE__*/ makeMap(`passive,once,capture`)
@ -146,9 +149,9 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
key = isStaticExp(key)
? createSimpleExpression(`${key.content}${modifierPostfix}`, true)
: createCompoundExpression([
`${context.helperString(CHECK_DYNAMIC_EVENT)}(`,
`${context.helperString(V_ON_WITH_DYNAMIC_EVENT_MODIFIERS)}(`,
key,
`,"${modifierPostfix}")`,
`, "${modifierPostfix}")`,
])
}

View File

@ -23,11 +23,3 @@ export function toHandlers(
}
return ret
}
export function checkDynamicEvent(
eventName: string,
modifierPostfix: string,
): string {
if (eventName != null && eventName !== '') return eventName + modifierPostfix
return ''
}

View File

@ -358,7 +358,7 @@ export {
withScopeId,
} from './componentRenderContext'
export { renderList } from './helpers/renderList'
export { toHandlers, checkDynamicEvent } from './helpers/toHandlers'
export { toHandlers } from './helpers/toHandlers'
export { renderSlot } from './helpers/renderSlot'
export { createSlots } from './helpers/createSlots'
export { withMemo, isMemoSame } from './helpers/withMemo'

View File

@ -160,4 +160,15 @@ export const withKeys = <T extends (event: KeyboardEvent) => any>(
)
}
/**
* @private
*/
export function withDynamicEventModifiers(
eventName: string,
modifierPostfix: string,
): string {
if (eventName != null && eventName !== '') return eventName + modifierPostfix
return ''
}
export type VOnDirective = Directive<any, any, VOnModifiers>

View File

@ -280,7 +280,11 @@ export {
vModelSelect,
vModelDynamic,
} from './directives/vModel'
export { withModifiers, withKeys } from './directives/vOn'
export {
withModifiers,
withKeys,
withDynamicEventModifiers,
} from './directives/vOn'
export { vShow } from './directives/vShow'
import { initVModelForSSR } from './directives/vModel'