diff --git a/dist/client/client_api.js b/dist/client/client_api.js index 175603ca9a5a..1d9402d1da32 100644 --- a/dist/client/client_api.js +++ b/dist/client/client_api.js @@ -90,7 +90,7 @@ var ClientApi = function () { // Remove events from the args. Otherwise, it creates a huge JSON string. args = args.map(function (arg) { - if (typeof arg.preventDefault === 'function') { + if (arg && typeof arg.preventDefault === 'function') { return '[SyntheticEvent]'; } return arg; diff --git a/src/client/__tests__/client_api.js b/src/client/__tests__/client_api.js index 700dd81535a0..5117cfea8ae8 100644 --- a/src/client/__tests__/client_api.js +++ b/src/client/__tests__/client_api.js @@ -125,6 +125,25 @@ describe('client.ClientApi', () => { }]); }); + it('should accept null and undefined values', () => { + const api = getClientApi(); + api._syncedStore.getData = () => ({ actions: [] }); + api._syncedStore.setData = sinon.stub(); + + const cb = api.action('hello'); + cb(null, void 0); + + const args = api._syncedStore.setData.args[0]; + const actions = clearActionId(args[0].actions); + expect(actions).to.be.deep.equal([{ + data: { + name: 'hello', + args: [null, void 0], + }, + count: 1, + }]); + }); + it('should only keep the latest 10 actions in the syncedStore', () => { const api = getClientApi(); api._syncedStore.getData = () => ({ diff --git a/src/client/client_api.js b/src/client/client_api.js index b3911f907e87..a32087be96a8 100644 --- a/src/client/client_api.js +++ b/src/client/client_api.js @@ -47,7 +47,7 @@ export default class ClientApi { // Remove events from the args. Otherwise, it creates a huge JSON string. args = args.map(arg => { - if (typeof arg.preventDefault === 'function') { + if (arg && typeof arg.preventDefault === 'function') { return '[SyntheticEvent]'; } return arg;