Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cases with missing targets #39

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 4 additions & 1 deletion src/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class Buffer {
value.replace(/[\(\)]/g, '').replace(/-/g, '_');

const value = strings
.map((str, i) => str + sanitize(values[i]))
.map((str, i) => {
const sanitized = sanitize(values[i]);
return sanitized ? str + sanitized : sanitized
})
.join('');

this.append(value);
Expand Down
6 changes: 4 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ const transitionActions = actions => {
const transitions = (stateNode, buffer) => {
const transition = ({ event, target, cond, actions }) => {
const from = stateNode.id;
const to = resolvePath(stateNode.parent || stateNode, target[0]);
// some events only trigger actions and don't cause a transition.
// setting to to stateNode.id would also work but is very verbose in diagrams
const to = target ? resolvePath(stateNode.parent || stateNode, target[0]): '';
const guards = transitionGuards(cond);
actions = transitionActions(actions);
buffer.appendf`${from} --> ${to} : ${event}${guards}${actions}`;
buffer.appendf`${from} --> ${to} : ${`${event}${guards}${actions}`}`;
};

if (stateNode.initial) {
Expand Down