Skip to content

Commit

Permalink
Check for events passed to action() in all arguments, rather than jus…
Browse files Browse the repository at this point in the history
…t the first
  • Loading branch information
Ashley Blurton committed Apr 21, 2016
1 parent af5970f commit 70a82a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 6 additions & 3 deletions dist/client/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ var ClientApi = function () {

// Remove events from the args. Otherwise, it creates a huge JSON string.

if (args[0] && typeof args[0].preventDefault === 'function') {
args[0] = '[SyntheticEvent]';
}
args = args.map(function (arg) {
if (typeof arg.preventDefault === 'function') {
return '[SyntheticEvent]';
}
return arg;
});

var id = ++idGenerator;
var data = { name: name, args: args };
Expand Down
14 changes: 7 additions & 7 deletions src/client/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ export default class ClientApi {
const syncedStore = this._syncedStore;

return function (..._args) {
const args = Array.from(_args);
let args = Array.from(_args);
let { actions = [] } = syncedStore.getData();

// Remove events from the args. Otherwise, it creates a huge JSON string.
if (
args[0] &&
typeof args[0].preventDefault === 'function'
) {
args[0] = '[SyntheticEvent]';
}
args = args.map(arg => {
if (typeof arg.preventDefault === 'function') {
return '[SyntheticEvent]';
}
return arg;
});

const id = ++idGenerator;
const data = { name, args };
Expand Down

0 comments on commit 70a82a6

Please sign in to comment.