chore: rename v-on guard constants

This commit is contained in:
Evan You 2019-10-18 16:36:42 -04:00
parent e98a85f3cb
commit 39ea67a2d2
3 changed files with 14 additions and 14 deletions

View File

@ -9,7 +9,7 @@ import {
Property
} from '@vue/compiler-core'
import { transformOn } from '../../src/transforms/vOn'
import { V_ON_MODIFIERS_GUARD, V_ON_KEYS_GUARD } from '../../src/runtimeHelpers'
import { V_ON_WITH_MODIFIERS, V_ON_WITH_KEYS } from '../../src/runtimeHelpers'
import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
import { transformExpression } from '../../../compiler-core/src/transforms/transformExpression'
import { createObjectMatcher } from '../../../compiler-core/__tests__/testUtils'
@ -38,7 +38,7 @@ describe('compiler-dom: transform v-on', () => {
expect(prop).toMatchObject({
type: NodeTypes.JS_PROPERTY,
value: {
callee: V_ON_MODIFIERS_GUARD,
callee: V_ON_WITH_MODIFIERS,
arguments: [{ content: '_ctx.test' }, '["stop","prevent"]']
}
})
@ -53,7 +53,7 @@ describe('compiler-dom: transform v-on', () => {
type: NodeTypes.JS_PROPERTY,
value: createObjectMatcher({
handler: {
callee: V_ON_MODIFIERS_GUARD,
callee: V_ON_WITH_MODIFIERS,
arguments: [{ content: '_ctx.test' }, '["stop"]']
},
options: createObjectMatcher({
@ -74,10 +74,10 @@ describe('compiler-dom: transform v-on', () => {
type: NodeTypes.JS_PROPERTY,
value: createObjectMatcher({
handler: {
callee: V_ON_KEYS_GUARD,
callee: V_ON_WITH_KEYS,
arguments: [
{
callee: V_ON_MODIFIERS_GUARD,
callee: V_ON_WITH_MODIFIERS,
arguments: [{ content: '_ctx.test' }, '["stop","ctrl"]']
},
'["a"]'
@ -98,7 +98,7 @@ describe('compiler-dom: transform v-on', () => {
expect(prop).toMatchObject({
type: NodeTypes.JS_PROPERTY,
value: {
callee: V_ON_MODIFIERS_GUARD,
callee: V_ON_WITH_MODIFIERS,
arguments: [{ content: '_ctx.test' }, '["exact"]']
}
})
@ -111,7 +111,7 @@ describe('compiler-dom: transform v-on', () => {
expect(prop).toMatchObject({
type: NodeTypes.JS_PROPERTY,
value: {
callee: V_ON_KEYS_GUARD,
callee: V_ON_WITH_KEYS,
arguments: [{ content: '_ctx.test' }, '["enter"]']
}
})

View File

@ -6,8 +6,8 @@ export const V_MODEL_TEXT = Symbol(__DEV__ ? `vModelText` : ``)
export const V_MODEL_SELECT = Symbol(__DEV__ ? `vModelSelect` : ``)
export const V_MODEL_DYNAMIC = Symbol(__DEV__ ? `vModelDynamic` : ``)
export const V_ON_MODIFIERS_GUARD = Symbol(__DEV__ ? `vOnModifiersGuard` : ``)
export const V_ON_KEYS_GUARD = Symbol(__DEV__ ? `vOnKeysGuard` : ``)
export const V_ON_WITH_MODIFIERS = Symbol(__DEV__ ? `vOnModifiersGuard` : ``)
export const V_ON_WITH_KEYS = Symbol(__DEV__ ? `vOnKeysGuard` : ``)
registerRuntimeHelpers({
[V_MODEL_RADIO]: `vModelRadio`,
@ -15,6 +15,6 @@ registerRuntimeHelpers({
[V_MODEL_TEXT]: `vModelText`,
[V_MODEL_SELECT]: `vModelSelect`,
[V_MODEL_DYNAMIC]: `vModelDynamic`,
[V_ON_MODIFIERS_GUARD]: `withModifiers`,
[V_ON_KEYS_GUARD]: `withKeys`
[V_ON_WITH_MODIFIERS]: `withModifiers`,
[V_ON_WITH_KEYS]: `withKeys`
})

View File

@ -7,7 +7,7 @@ import {
createSimpleExpression,
NodeTypes
} from '@vue/compiler-core'
import { V_ON_MODIFIERS_GUARD, V_ON_KEYS_GUARD } from '../runtimeHelpers'
import { V_ON_WITH_MODIFIERS, V_ON_WITH_KEYS } from '../runtimeHelpers'
import { makeMap } from '@vue/shared'
const isEventOptionModifier = /*#__PURE__*/ makeMap(`passive,once,capture`)
@ -39,7 +39,7 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
// built-in modifiers that are not keys
const nonKeyModifiers = runtimeModifiers.filter(isNonKeyModifier)
if (nonKeyModifiers.length) {
handlerExp = createCallExpression(context.helper(V_ON_MODIFIERS_GUARD), [
handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
handlerExp,
JSON.stringify(nonKeyModifiers)
])
@ -53,7 +53,7 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
!key.isStatic ||
isKeyboardEvent(key.content))
) {
handlerExp = createCallExpression(context.helper(V_ON_KEYS_GUARD), [
handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
handlerExp,
JSON.stringify(keyModifiers)
])