Skip to content

Commit

Permalink
Fix #321: Ensure vars are given to formatText().
Browse files Browse the repository at this point in the history
(key in variables) crashes if variables is undefined or null.
It must be made safe with (variables && key in variables).
  • Loading branch information
cburschka committed Dec 30, 2015
1 parent e9b8073 commit 82ec347
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/core/visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ visual = {
if (typeof(text) === 'string') text = $('<span>').text(text);
text.find('*').addBack() // include all descendants and the top element.
.replaceText(/({(?:(\w+):)?(\w+)})/g, function(rep, format, key) {
if (key in variables) {
if (variables && key in variables) {
if ((format || key) in visual.format) {
return visual.format[format || key](variables[key]);
}
Expand Down

0 comments on commit 82ec347

Please sign in to comment.