mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
parent
2004e7065a
commit
b26c6221f1
1 changed files with 11 additions and 4 deletions
|
@ -225,15 +225,22 @@ Base.exports.PaperScript = (function() {
|
||||||
|| parentType === 'MemberExpression' && parent.computed
|
|| parentType === 'MemberExpression' && parent.computed
|
||||||
)) {
|
)) {
|
||||||
if (node.type === 'UpdateExpression') {
|
if (node.type === 'UpdateExpression') {
|
||||||
var arg = getCode(node.argument);
|
var arg = getCode(node.argument),
|
||||||
var str = arg + ' = __$__(' + arg
|
exp = '__$__(' + arg + ', "' + node.operator[0]
|
||||||
+ ', "' + node.operator[0] + '", 1)';
|
+ '", 1)',
|
||||||
|
str = arg + ' = ' + exp;
|
||||||
// If this is not a prefixed update expression
|
// If this is not a prefixed update expression
|
||||||
// (++a, --a), assign the old value before updating it.
|
// (++a, --a), assign the old value before updating it.
|
||||||
if (!node.prefix
|
if (!node.prefix
|
||||||
&& (parentType === 'AssignmentExpression'
|
&& (parentType === 'AssignmentExpression'
|
||||||
|| parentType === 'VariableDeclarator'))
|
|| parentType === 'VariableDeclarator')) {
|
||||||
|
// Handle special issue #691 where the old value is
|
||||||
|
// assigned to itself, and the expression is just
|
||||||
|
// executed after, e.g.: `var x = ***; x = x++;`
|
||||||
|
if (getCode(parent.left || parent.id) === arg)
|
||||||
|
str = exp;
|
||||||
str = arg + '; ' + str;
|
str = arg + '; ' + str;
|
||||||
|
}
|
||||||
replaceCode(node, str);
|
replaceCode(node, str);
|
||||||
} else { // AssignmentExpression
|
} else { // AssignmentExpression
|
||||||
if (/^.=$/.test(node.operator)
|
if (/^.=$/.test(node.operator)
|
||||||
|
|
Loading…
Reference in a new issue