Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/client/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions src/client/__tests__/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => ({
Expand Down
2 changes: 1 addition & 1 deletion src/client/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down