File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ var ClientApi = function () {
9090 // Remove events from the args. Otherwise, it creates a huge JSON string.
9191
9292 args = args . map ( function ( arg ) {
93- if ( typeof arg . preventDefault === 'function' ) {
93+ if ( arg && typeof arg . preventDefault === 'function' ) {
9494 return '[SyntheticEvent]' ;
9595 }
9696 return arg ;
Original file line number Diff line number Diff line change @@ -125,6 +125,25 @@ describe('client.ClientApi', () => {
125125 } ] ) ;
126126 } ) ;
127127
128+ it ( 'should accept null and undefined values' , ( ) => {
129+ const api = getClientApi ( ) ;
130+ api . _syncedStore . getData = ( ) => ( { actions : [ ] } ) ;
131+ api . _syncedStore . setData = sinon . stub ( ) ;
132+
133+ const cb = api . action ( 'hello' ) ;
134+ cb ( null , void 0 ) ;
135+
136+ const args = api . _syncedStore . setData . args [ 0 ] ;
137+ const actions = clearActionId ( args [ 0 ] . actions ) ;
138+ expect ( actions ) . to . be . deep . equal ( [ {
139+ data : {
140+ name : 'hello' ,
141+ args : [ null , void 0 ] ,
142+ } ,
143+ count : 1 ,
144+ } ] ) ;
145+ } ) ;
146+
128147 it ( 'should only keep the latest 10 actions in the syncedStore' , ( ) => {
129148 const api = getClientApi ( ) ;
130149 api . _syncedStore . getData = ( ) => ( {
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export default class ClientApi {
4747
4848 // Remove events from the args. Otherwise, it creates a huge JSON string.
4949 args = args . map ( arg => {
50- if ( typeof arg . preventDefault === 'function' ) {
50+ if ( arg && typeof arg . preventDefault === 'function' ) {
5151 return '[SyntheticEvent]' ;
5252 }
5353 return arg ;
You can’t perform that action at this time.
0 commit comments