)
// left & right could be mouse or key modifiers based on event type
const maybeKeyModifier = /*@__PURE__*/ makeMap('left,right')
-const isKeyboardEvent = /*@__PURE__*/ makeMap(
- `onkeyup,onkeydown,onkeypress`,
- true,
-)
+const isKeyboardEvent = /*@__PURE__*/ makeMap(`onkeyup,onkeydown,onkeypress`)
const resolveModifiers = (
key: ExpressionNode,
// runtimeModifiers: modifiers that needs runtime guards
if (maybeKeyModifier(modifier)) {
if (isStaticExp(key)) {
- if (isKeyboardEvent((key as SimpleExpressionNode).content)) {
+ if (
+ isKeyboardEvent((key as SimpleExpressionNode).content.toLowerCase())
+ ) {
keyModifiers.push(modifier)
} else {
nonKeyModifiers.push(modifier)
if (
keyModifiers.length &&
// if event name is dynamic, always wrap with keys guard
- (!isStaticExp(key) || isKeyboardEvent(key.content))
+ (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))
) {
handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
handlerExp,
*/
/*! #__NO_SIDE_EFFECTS__ */
-export function makeMap(
- str: string,
- expectsLowerCase?: boolean,
-): (key: string) => boolean {
- const set = new Set(str.split(','))
- return expectsLowerCase
- ? val => set.has(val.toLowerCase())
- : val => set.has(val)
+export function makeMap(str: string): (key: string) => boolean {
+ const map = Object.create(null)
+ for (const key of str.split(',')) map[key] = 1
+ return val => val in map
}