File tree 2 files changed +44
-1
lines changed
test/unit/specs/directives/public
2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const keyCodes = {
7
7
tab : 9 ,
8
8
enter : 13 ,
9
9
space : 32 ,
10
- 'delete' : 46 ,
10
+ 'delete' : [ 8 , 46 ] ,
11
11
up : 38 ,
12
12
left : 37 ,
13
13
right : 39 ,
@@ -28,6 +28,7 @@ function keyFilter (handler, keys) {
28
28
}
29
29
return keyCodes [ key ]
30
30
} )
31
+ codes = [ ] . concat . apply ( [ ] , codes )
31
32
return function keyHandler ( e ) {
32
33
if ( codes . indexOf ( e . keyCode ) > - 1 ) {
33
34
return handler . call ( this , e )
Original file line number Diff line number Diff line change @@ -88,6 +88,48 @@ describe('v-on', function () {
88
88
} )
89
89
} )
90
90
91
+ it ( 'with delete modifier capturing DEL' , function ( done ) {
92
+ new Vue ( {
93
+ el : el ,
94
+ template : '<a v-on:keyup.delete="test">{{a}}</a>' ,
95
+ data : { a : 1 } ,
96
+ methods : {
97
+ test : function ( ) {
98
+ this . a ++
99
+ }
100
+ }
101
+ } )
102
+ var a = el . firstChild
103
+ trigger ( a , 'keyup' , function ( e ) {
104
+ e . keyCode = 46
105
+ } )
106
+ _ . nextTick ( function ( ) {
107
+ expect ( a . textContent ) . toBe ( '2' )
108
+ done ( )
109
+ } )
110
+ } )
111
+
112
+ it ( 'with delete modifier capturing backspace' , function ( done ) {
113
+ new Vue ( {
114
+ el : el ,
115
+ template : '<a v-on:keyup.delete="test">{{a}}</a>' ,
116
+ data : { a : 1 } ,
117
+ methods : {
118
+ test : function ( ) {
119
+ this . a ++
120
+ }
121
+ }
122
+ } )
123
+ var a = el . firstChild
124
+ trigger ( a , 'keyup' , function ( e ) {
125
+ e . keyCode = 8
126
+ } )
127
+ _ . nextTick ( function ( ) {
128
+ expect ( a . textContent ) . toBe ( '2' )
129
+ done ( )
130
+ } )
131
+ } )
132
+
91
133
it ( 'with key modifier (keycode)' , function ( done ) {
92
134
new Vue ( {
93
135
el : el ,
You can’t perform that action at this time.
0 commit comments