File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
test/unit/specs/directives/public Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,17 @@ var keyCodes = {
15
15
16
16
function keyFilter ( handler , keys ) {
17
17
var codes = keys . map ( function ( key ) {
18
- var code = keyCodes [ key ]
19
- if ( ! code ) {
20
- code = parseInt ( key , 10 )
18
+ var charCode = key . charCodeAt ( 0 )
19
+ if ( charCode > 47 && charCode < 58 ) {
20
+ return parseInt ( key , 10 )
21
21
}
22
- return code
22
+ if ( key . length === 1 ) {
23
+ charCode = key . toUpperCase ( ) . charCodeAt ( 0 )
24
+ if ( charCode > 64 && charCode < 91 ) {
25
+ return charCode
26
+ }
27
+ }
28
+ return keyCodes [ key ]
23
29
} )
24
30
return function keyHandler ( e ) {
25
31
if ( codes . indexOf ( e . keyCode ) > - 1 ) {
Original file line number Diff line number Diff line change @@ -110,6 +110,27 @@ if (_.inBrowser) {
110
110
} )
111
111
} )
112
112
113
+ it ( 'with key modifier (letter)' , function ( done ) {
114
+ new Vue ( {
115
+ el : el ,
116
+ template : '<a v-on:keyup.a="test">{{a}}</a>' ,
117
+ data : { a : 1 } ,
118
+ methods : {
119
+ test : function ( ) {
120
+ this . a ++
121
+ }
122
+ }
123
+ } )
124
+ var a = el . firstChild
125
+ trigger ( a , 'keyup' , function ( e ) {
126
+ e . keyCode = 65
127
+ } )
128
+ _ . nextTick ( function ( ) {
129
+ expect ( a . textContent ) . toBe ( '2' )
130
+ done ( )
131
+ } )
132
+ } )
133
+
113
134
it ( 'stop modifier' , function ( ) {
114
135
var outer = jasmine . createSpy ( 'outer' )
115
136
var inner = jasmine . createSpy ( 'inner' )
You can’t perform that action at this time.
0 commit comments