Skip to content

Commit

Permalink
Merge pull request #30 from storybooks/support-action-wihtout-names
Browse files Browse the repository at this point in the history
Support actions without names
  • Loading branch information
Muhammed Thanish committed Mar 22, 2017
2 parents 582e865 + bf06803 commit 0736b07
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function action(name) {
// the same.
//
// Ref: https://bocoup.com/weblog/whats-in-a-function-name
var fnName = name.replace(/\W+/g, '_');
var fnName = name ? name.replace(/\W+/g, '_') : 'action';
var named = eval('(function ' + fnName + '() { return handler.apply(this, arguments) })');
return named;
}
Expand Down
2 changes: 1 addition & 1 deletion src/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function action(name) {
// the same.
//
// Ref: https://bocoup.com/weblog/whats-in-a-function-name
const fnName = name.replace(/\W+/g,'_');
const fnName = name ? name.replace(/\W+/g,'_') : 'action';
const named = eval(`(function ${fnName}() { return handler.apply(this, arguments) })`)
return named
}
Expand Down

0 comments on commit 0736b07

Please sign in to comment.