File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed
test/unit/specs/directives/public Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const keyCodes = {
77 tab : 9 ,
88 enter : 13 ,
99 space : 32 ,
10- 'delete' : 46 ,
10+ 'delete' : [ 8 , 46 ] ,
1111 up : 38 ,
1212 left : 37 ,
1313 right : 39 ,
@@ -28,6 +28,7 @@ function keyFilter (handler, keys) {
2828 }
2929 return keyCodes [ key ]
3030 } )
31+ codes = [ ] . concat . apply ( [ ] , codes )
3132 return function keyHandler ( e ) {
3233 if ( codes . indexOf ( e . keyCode ) > - 1 ) {
3334 return handler . call ( this , e )
Original file line number Diff line number Diff line change @@ -88,6 +88,48 @@ describe('v-on', function () {
8888 } )
8989 } )
9090
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+
91133 it ( 'with key modifier (keycode)' , function ( done ) {
92134 new Vue ( {
93135 el : el ,
You can’t perform that action at this time.
0 commit comments