mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -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)
|
if (/^.=$/.test(node.operator)
|
||||||
&& node.left.type !== 'Literal') {
|
&& node.left.type !== 'Literal') {
|
||||||
var left = getCode(node.left),
|
var left = getCode(node.left),
|
||||||
right = getCode(node.right);
|
right = getCode(node.right),
|
||||||
replaceCode(node, left + ' = __$__(' + left + ', "'
|
exp = left + ' = __$__(' + left + ', "'
|
||||||
+ node.operator[0] + '", ' + right + ')');
|
+ 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