Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions src/compiler/codegen/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ function genHandler(
}
} else if (key === 'exact') {
const modifiers = handler.modifiers
genModifierCode += genGuard(
['ctrl', 'shift', 'alt', 'meta']
.filter(keyModifier => !modifiers[keyModifier])
.map(keyModifier => `$event.${keyModifier}Key`)
.join('||')
)
const exactModifiers = ['ctrl', 'shift', 'alt', 'meta']
.filter(keyModifier => !modifiers[keyModifier])
.map(keyModifier => `$event.${keyModifier}Key`)
.join('||')
if (exactModifiers) {
genModifierCode += genGuard(exactModifiers)
}
} else {
keys.push(key)
}
Expand Down
5 changes: 5 additions & 0 deletions test/unit/modules/compiler/codegen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ describe('codegen', () => {
'<input @click.ctrl.exact="onClick">',
`with(this){return _c('input',{on:{"click":function($event){if(!$event.ctrlKey)return null;if($event.shiftKey||$event.altKey||$event.metaKey)return null;return onClick.apply(null, arguments)}}})}`
)
// #12319: all system modifiers with .exact should not generate syntax error
assertCodegen(
'<input @keydown.ctrl.shift.alt.meta.exact="onKeydown">',
`with(this){return _c('input',{on:{"keydown":function($event){if(!$event.ctrlKey)return null;if(!$event.shiftKey)return null;if(!$event.altKey)return null;if(!$event.metaKey)return null;return onKeydown.apply(null, arguments)}}})}`
)
})

it('generate events with multiple modifiers', () => {
Expand Down