Skip to content

Commit

Permalink
fix edge case for generator where a node only has beforeGenerated spe…
Browse files Browse the repository at this point in the history
…cial directives while generating
  • Loading branch information
kbrsh committed Feb 19, 2017
1 parent 4a4e584 commit 7ffcf7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@
delete props[prop];
}
}

if (props[prop]) {
generatedObject += '"' + prop + '": ' + compileTemplate(JSON.stringify(props[prop]), true) + ', ';
}
Expand Down
6 changes: 6 additions & 0 deletions src/compiler/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ var generateProps = function(vnode) {
delete props[prop];
}
}

// If the only props were special directives, there might be no props, return an empty object
if(Object.keys(props).length === 0) {
return "{}";
}

if(props[prop]) {
generatedObject += `"${prop}": ${compileTemplate(JSON.stringify(props[prop]), true)}, `;
}
Expand Down

0 comments on commit 7ffcf7a

Please sign in to comment.