diff --git a/lib/output.js b/lib/output.js index 9f472ce6..1e0ff175 100644 --- a/lib/output.js +++ b/lib/output.js @@ -635,6 +635,11 @@ function OutputStream(options) { return false; }); + PARENS(AST_Arrow, function(output){ + var p = output.parent(); + return p instanceof AST_PropAccess && p.expression === this; + }); + // same goes for an object literal, because otherwise it would be // interpreted as a block of code. PARENS(AST_Object, function(output){ diff --git a/test/mocha/arrow.js b/test/mocha/arrow.js index 1ee6d403..7de4c1fa 100644 --- a/test/mocha/arrow.js +++ b/test/mocha/arrow.js @@ -382,4 +382,22 @@ describe("Arrow functions", function() { assert(ast.body[0].definitions[0].value.argnames[0].names[0].value.names[1].expression instanceof uglify.AST_SymbolFunarg); }); + it("Should handle arrow function with bind", function() { + function minify(code) { + return uglify.minify(code, { + fromString: true, + mangle: false + }).code; + } + + assert.strictEqual( + minify(minify("test(((index) => { console.log(this, index); }).bind(this, 1));")), + "test((index=>{console.log(this,index)}).bind(this,1));" + ); + assert.strictEqual( + minify(minify('test(((index) => { console.log(this, index); })["bind"](this, 1));')), + "test((index=>{console.log(this,index)}).bind(this,1));" + ); + }); + });