mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
parent
aca3059814
commit
80131f0398
3 changed files with 27 additions and 0 deletions
|
@ -268,6 +268,11 @@ Base.exports.PaperScript = function() {
|
|||
str = exp;
|
||||
str = arg + '; ' + str;
|
||||
}
|
||||
// If this is a prefixed update expression (++a / --a),
|
||||
// wrap expression in IIFE to avoid several bugs (#1450)
|
||||
if (node.prefix) {
|
||||
str = '(function(){return '+str+';})()';
|
||||
}
|
||||
replaceCode(node, str);
|
||||
} else { // AssignmentExpression
|
||||
if (/^.=$/.test(node.operator)
|
||||
|
|
20
test/tests/PaperScript.js
Normal file
20
test/tests/PaperScript.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
||||
* http://paperjs.org/
|
||||
*
|
||||
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
||||
* http://scratchdisk.com/ & https://puckey.studio/
|
||||
*
|
||||
* Distributed under the MIT license. See LICENSE file for details.
|
||||
*
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
QUnit.module('PaperScript');
|
||||
|
||||
test('PaperScript#compile() with prefix increment/decrement operators', function() {
|
||||
var code = 'var x = 1; var y = 1 * --x;';
|
||||
var compiled = PaperScript.compile(code, paper);
|
||||
PaperScript.execute(compiled, paper);
|
||||
expect(0);
|
||||
});
|
|
@ -63,6 +63,8 @@
|
|||
|
||||
/*#*/ include('Numerical.js');
|
||||
|
||||
/*#*/ include('PaperScript.js');
|
||||
|
||||
// There is no need to test interactions in node context.
|
||||
if (!isNodeContext) {
|
||||
/*#*/ include('Interactions.js');
|
||||
|
|
Loading…
Reference in a new issue