mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
PaperScript: Prevent invalid JavaScript in assignment operators.
Closes #1151
This commit is contained in:
parent
3c43a78c53
commit
d779789b6f
1 changed files with 7 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue