MCPcopy
hub / github.com/vuejs/core / resolveModifiers

Function resolveModifiers

packages/compiler-dom/src/transforms/vOn.ts:33–90  ·  view source on GitHub ↗
(
  key: ExpressionNode,
  modifiers: SimpleExpressionNode[],
  context: TransformContext,
  loc: SourceLocation,
)

Source from the content-addressed store, hash-verified

31const isKeyboardEvent = /*@__PURE__*/ makeMap(`onkeyup,onkeydown,onkeypress`)
32
33const resolveModifiers = (
34 key: ExpressionNode,
35 modifiers: SimpleExpressionNode[],
36 context: TransformContext,
37 loc: SourceLocation,
38) => {
39 const keyModifiers = []
40 const nonKeyModifiers = []
41 const eventOptionModifiers = []
42
43 for (let i = 0; i < modifiers.length; i++) {
44 const modifier = modifiers[i].content
45
46 if (
47 __COMPAT__ &&
48 modifier === 'native' &&
49 checkCompatEnabled(
50 CompilerDeprecationTypes.COMPILER_V_ON_NATIVE,
51 context,
52 loc,
53 )
54 ) {
55 eventOptionModifiers.push(modifier)
56 } else if (isEventOptionModifier(modifier)) {
57 // eventOptionModifiers: modifiers for addEventListener() options,
58 // e.g. .passive & .capture
59 eventOptionModifiers.push(modifier)
60 } else {
61 // runtimeModifiers: modifiers that needs runtime guards
62 if (maybeKeyModifier(modifier)) {
63 if (isStaticExp(key)) {
64 if (
65 isKeyboardEvent((key as SimpleExpressionNode).content.toLowerCase())
66 ) {
67 keyModifiers.push(modifier)
68 } else {
69 nonKeyModifiers.push(modifier)
70 }
71 } else {
72 keyModifiers.push(modifier)
73 nonKeyModifiers.push(modifier)
74 }
75 } else {
76 if (isNonKeyModifier(modifier)) {
77 nonKeyModifiers.push(modifier)
78 } else {
79 keyModifiers.push(modifier)
80 }
81 }
82 }
83 }
84
85 return {
86 keyModifiers,
87 nonKeyModifiers,
88 eventOptionModifiers,
89 }
90}

Callers 1

transformOnFunction · 0.85

Calls 3

checkCompatEnabledFunction · 0.90
isStaticExpFunction · 0.90
pushMethod · 0.65

Tested by

no test coverage detected