Skip to content

Commit d2d2e3d

Browse files
committed
chore: update
1 parent 60a554c commit d2d2e3d

File tree

8 files changed

+32
-22
lines changed

8 files changed

+32
-22
lines changed

packages/compiler-core/src/runtimeHelpers.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ export const CAPITALIZE: unique symbol = Symbol(__DEV__ ? `capitalize` : ``)
6363
export const TO_HANDLER_KEY: unique symbol = Symbol(
6464
__DEV__ ? `toHandlerKey` : ``,
6565
)
66-
export const CHECK_DYNAMIC_EVENT: unique symbol = Symbol(
67-
__DEV__ ? `checkDynamicEvent` : ``,
68-
)
6966
export const SET_BLOCK_TRACKING: unique symbol = Symbol(
7067
__DEV__ ? `setBlockTracking` : ``,
7168
)
@@ -118,7 +115,6 @@ export const helperNameMap: Record<symbol, string> = {
118115
[CAMELIZE]: `camelize`,
119116
[CAPITALIZE]: `capitalize`,
120117
[TO_HANDLER_KEY]: `toHandlerKey`,
121-
[CHECK_DYNAMIC_EVENT]: `checkDynamicEvent`,
122118
[SET_BLOCK_TRACKING]: `setBlockTracking`,
123119
[PUSH_SCOPE_ID]: `pushScopeId`,
124120
[POP_SCOPE_ID]: `popScopeId`,

packages/compiler-dom/__tests__/transforms/__snapshots__/vOn.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ exports[`compiler-dom: transform v-on > should wrap both for dynamic key event w
55
66
return function render(_ctx, _cache) {
77
with (_ctx) {
8-
const { toHandlerKey: _toHandlerKey, checkDynamicEvent: _checkDynamicEvent, createElementVNode: _createElementVNode, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
8+
const { toHandlerKey: _toHandlerKey, withDynamicEventModifiers: _withDynamicEventModifiers, createElementVNode: _createElementVNode, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
99
1010
return (_openBlock(), _createElementBlock(_Fragment, null, [
11-
_createElementVNode("div", { [_checkDynamicEvent(_toHandlerKey(e),"Once")]: test }, null, 16 /* FULL_PROPS */),
12-
_createElementVNode("div", { [_checkDynamicEvent(_toHandlerKey(e),"Passive")]: test }, null, 16 /* FULL_PROPS */),
13-
_createElementVNode("div", { [_checkDynamicEvent(_toHandlerKey(e),"Capture")]: test }, null, 16 /* FULL_PROPS */)
11+
_createElementVNode("div", { [_withDynamicEventModifiers(_toHandlerKey(e), "Once")]: test }, null, 16 /* FULL_PROPS */),
12+
_createElementVNode("div", { [_withDynamicEventModifiers(_toHandlerKey(e), "Passive")]: test }, null, 16 /* FULL_PROPS */),
13+
_createElementVNode("div", { [_withDynamicEventModifiers(_toHandlerKey(e), "Capture")]: test }, null, 16 /* FULL_PROPS */)
1414
], 64 /* STABLE_FRAGMENT */))
1515
}
1616
}"

packages/compiler-dom/src/runtimeHelpers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export const V_ON_WITH_MODIFIERS: unique symbol = Symbol(
1818
export const V_ON_WITH_KEYS: unique symbol = Symbol(
1919
__DEV__ ? `vOnKeysGuard` : ``,
2020
)
21+
export const V_ON_WITH_DYNAMIC_EVENT_MODIFIERS: unique symbol = Symbol(
22+
__DEV__ ? `vOnDynamicEventModifiers` : ``,
23+
)
2124

2225
export const V_SHOW: unique symbol = Symbol(__DEV__ ? `vShow` : ``)
2326

@@ -34,6 +37,7 @@ registerRuntimeHelpers({
3437
[V_MODEL_DYNAMIC]: `vModelDynamic`,
3538
[V_ON_WITH_MODIFIERS]: `withModifiers`,
3639
[V_ON_WITH_KEYS]: `withKeys`,
40+
[V_ON_WITH_DYNAMIC_EVENT_MODIFIERS]: `withDynamicEventModifiers`,
3741
[V_SHOW]: `vShow`,
3842
[TRANSITION]: `Transition`,
3943
[TRANSITION_GROUP]: `TransitionGroup`,

packages/compiler-dom/src/transforms/vOn.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
CHECK_DYNAMIC_EVENT,
32
CompilerDeprecationTypes,
43
type DirectiveTransform,
54
type ExpressionNode,
@@ -15,7 +14,11 @@ import {
1514
createSimpleExpression,
1615
isStaticExp,
1716
} from '@vue/compiler-core'
18-
import { V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS } from '../runtimeHelpers'
17+
import {
18+
V_ON_WITH_DYNAMIC_EVENT_MODIFIERS,
19+
V_ON_WITH_KEYS,
20+
V_ON_WITH_MODIFIERS,
21+
} from '../runtimeHelpers'
1922
import { capitalize, makeMap } from '@vue/shared'
2023

2124
const isEventOptionModifier = /*@__PURE__*/ makeMap(`passive,once,capture`)
@@ -146,9 +149,9 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
146149
key = isStaticExp(key)
147150
? createSimpleExpression(`${key.content}${modifierPostfix}`, true)
148151
: createCompoundExpression([
149-
`${context.helperString(CHECK_DYNAMIC_EVENT)}(`,
152+
`${context.helperString(V_ON_WITH_DYNAMIC_EVENT_MODIFIERS)}(`,
150153
key,
151-
`,"${modifierPostfix}")`,
154+
`, "${modifierPostfix}")`,
152155
])
153156
}
154157

packages/runtime-core/src/helpers/toHandlers.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,3 @@ export function toHandlers(
2323
}
2424
return ret
2525
}
26-
27-
export function checkDynamicEvent(
28-
eventName: string,
29-
modifierPostfix: string,
30-
): string {
31-
if (eventName != null && eventName !== '') return eventName + modifierPostfix
32-
return ''
33-
}

packages/runtime-core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export {
358358
withScopeId,
359359
} from './componentRenderContext'
360360
export { renderList } from './helpers/renderList'
361-
export { toHandlers, checkDynamicEvent } from './helpers/toHandlers'
361+
export { toHandlers } from './helpers/toHandlers'
362362
export { renderSlot } from './helpers/renderSlot'
363363
export { createSlots } from './helpers/createSlots'
364364
export { withMemo, isMemoSame } from './helpers/withMemo'

packages/runtime-dom/src/directives/vOn.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,15 @@ export const withKeys = <T extends (event: KeyboardEvent) => any>(
160160
)
161161
}
162162

163+
/**
164+
* @private
165+
*/
166+
export function withDynamicEventModifiers(
167+
eventName: string,
168+
modifierPostfix: string,
169+
): string {
170+
if (eventName != null && eventName !== '') return eventName + modifierPostfix
171+
return ''
172+
}
173+
163174
export type VOnDirective = Directive<any, any, VOnModifiers>

packages/runtime-dom/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,11 @@ export {
280280
vModelSelect,
281281
vModelDynamic,
282282
} from './directives/vModel'
283-
export { withModifiers, withKeys } from './directives/vOn'
283+
export {
284+
withModifiers,
285+
withKeys,
286+
withDynamicEventModifiers,
287+
} from './directives/vOn'
284288
export { vShow } from './directives/vShow'
285289

286290
import { initVModelForSSR } from './directives/vModel'

0 commit comments

Comments
 (0)