diff --git a/src/core/PaperScript.js b/src/core/PaperScript.js index 560094d0..e316f6c3 100644 --- a/src/core/PaperScript.js +++ b/src/core/PaperScript.js @@ -251,9 +251,13 @@ Base.exports.PaperScript = function() { if (/^.=$/.test(node.operator) && node.left.type !== 'Literal') { var left = getCode(node.left), - right = getCode(node.right); - replaceCode(node, left + ' = __$__(' + left + ', "' - + node.operator[0] + '", ' + right + ')'); + right = getCode(node.right), + exp = left + ' = __$__(' + left + ', "' + + node.operator[0] + '", ' + right + ')'; + // If the original expression is wrapped in + // parenthesis, do the same with the replacement: + replaceCode(node, /^\(.*\)$/.test(getCode(node)) + ? '(' + exp + ')' : exp); } } }