Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/corePublic

fix: handle nullish dynamic event name with event modifiers#13060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
linzhe141 wants to merge5 commits intovuejs:main
base:main
Choose a base branch
Loading
fromlinzhe141:fix-nullish-dynamic-event
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
fix: handle nullish dynamic event name with a modifier
  • Loading branch information
@linzhe141
linzhe141 committedMar 18, 2025
commitf0705607414ebda4d28de823e6a5cbad0302db20
4 changes: 4 additions & 0 deletionspackages/compiler-core/src/runtimeHelpers.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,6 +63,9 @@ 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` : ``,
)
Expand DownExpand Up@@ -115,6 +118,7 @@ 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`,
Expand Down
7 changes: 6 additions & 1 deletionpackages/compiler-dom/src/transforms/vOn.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
import {
CHECK_DYNAMIC_EVENT,
CompilerDeprecationTypes,
type DirectiveTransform,
type ExpressionNode,
Expand DownExpand Up@@ -144,7 +145,11 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
const modifierPostfix = eventOptionModifiers.map(capitalize).join('')
key = isStaticExp(key)
? createSimpleExpression(`${key.content}${modifierPostfix}`, true)
: createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`])
: createCompoundExpression([
`${context.helperString(CHECK_DYNAMIC_EVENT)}(`,
key,
`,"${modifierPostfix}")`,
])
}

return {
Expand Down
8 changes: 8 additions & 0 deletionspackages/runtime-core/src/helpers/toHandlers.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,3 +23,11 @@ export function toHandlers(
}
return ret
}

export function checkDynamicEvent(
eventName: string,
modifierPostfix: string,
): string {
if (eventName != null && eventName !== '') return eventName + modifierPostfix
return ''
}
2 changes: 1 addition & 1 deletionpackages/runtime-core/src/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -358,7 +358,7 @@ export {
withScopeId,
} from './componentRenderContext'
export { renderList } from './helpers/renderList'
export { toHandlers } from './helpers/toHandlers'
export { toHandlers, checkDynamicEvent } from './helpers/toHandlers'
export { renderSlot } from './helpers/renderSlot'
export { createSlots } from './helpers/createSlots'
export { withMemo, isMemoSame } from './helpers/withMemo'
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp