File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
test/unit/modules/compiler Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,11 @@ const keyCodes = {
1818const modifierCode = {
1919 stop : '$event.stopPropagation();' ,
2020 prevent : '$event.preventDefault();' ,
21- self : 'if($event.target !== $event.currentTarget)return;'
21+ self : 'if($event.target !== $event.currentTarget)return;' ,
22+ ctrl : 'if(!$event.ctrlKey)return;' ,
23+ shift : 'if(!$event.shiftKey)return;' ,
24+ alt : 'if(!$event.altKey)return;' ,
25+ meta : 'if(!$event.metaKey)return;'
2226}
2327
2428export function genHandlers ( events : ASTElementHandlers , native ?: boolean ) : string {
Original file line number Diff line number Diff line change @@ -224,6 +224,22 @@ describe('codegen', () => {
224224 '<input @input.self="onInput">' ,
225225 `with(this){return _h('input',{on:{"input":function($event){if($event.target !== $event.currentTarget)return;onInput($event)}}})}`
226226 )
227+ assertCodegen (
228+ '<input @input.ctrl="onInput">' ,
229+ `with(this){return _h('input',{on:{"input":function($event){if(!$event.ctrlKey)return;onInput($event)}}})}`
230+ )
231+ assertCodegen (
232+ '<input @input.shift="onInput">' ,
233+ `with(this){return _h('input',{on:{"input":function($event){if(!$event.shiftKey)return;onInput($event)}}})}`
234+ )
235+ assertCodegen (
236+ '<input @input.alt="onInput">' ,
237+ `with(this){return _h('input',{on:{"input":function($event){if(!$event.altKey)return;onInput($event)}}})}`
238+ )
239+ assertCodegen (
240+ '<input @input.meta="onInput">' ,
241+ `with(this){return _h('input',{on:{"input":function($event){if(!$event.metaKey)return;onInput($event)}}})}`
242+ )
227243 } )
228244
229245 it ( 'generate events with multiple modifers' , ( ) => {
You can’t perform that action at this time.
0 commit comments