diff --git a/CHANGELOG.md b/CHANGELOG.md index 9af45c0359..ec4543fcfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,14 @@ _Note: Gaps between patch versions are faulty/broken releases._ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. +## 4.7.13 + + * **Bug Fix** + * Handle comments on use strict directives. + * Fix assignment patterns with a left side pattern. + * **Polish** + * Special case `this` when doing expression memoisation. + ## 4.7.12 * **Bug Fix** diff --git a/package.json b/package.json index 592e852363..4e0462831a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "babel", "description": "Turn ES6 code into readable vanilla ES5 with source maps", - "version": "4.7.12", + "version": "4.7.13", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", "repository": "babel/babel", diff --git a/packages/babel-runtime/package.json b/packages/babel-runtime/package.json index 327320ef59..2a9557a226 100644 --- a/packages/babel-runtime/package.json +++ b/packages/babel-runtime/package.json @@ -1,7 +1,7 @@ { "name": "babel-runtime", "description": "babel selfContained runtime", - "version": "4.7.12", + "version": "4.7.13", "repository": "babel/babel", "author": "Sebastian McKenzie ", "dependencies": { diff --git a/src/babel/transformation/transformers/es6/destructuring.js b/src/babel/transformation/transformers/es6/destructuring.js index a27e70c907..9664315737 100644 --- a/src/babel/transformation/transformers/es6/destructuring.js +++ b/src/babel/transformation/transformers/es6/destructuring.js @@ -290,14 +290,21 @@ class DestructuringTransformer { // - this.nodes.push(this.buildVariableAssignment( - pattern.left, - t.conditionalExpression( - t.binaryExpression("===", tempValueRef, t.identifier("undefined")), - pattern.right, - tempValueRef - ) - )); + var tempConditional = t.conditionalExpression( + t.binaryExpression("===", tempValueRef, t.identifier("undefined")), + pattern.right, + tempValueRef + ); + + var left = pattern.left; + if (t.isPattern(left)) { + this.nodes.push(t.expressionStatement( + t.assignmentExpression("=", tempValueRef, tempConditional) + )); + this.push(left, tempValueRef); + } else { + this.nodes.push(this.buildVariableAssignment(left, tempConditional)); + } } pushObjectSpread(pattern, objRef, spreadProp, spreadPropIndex) { diff --git a/test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/actual.js b/test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/actual.js new file mode 100644 index 0000000000..95a96ebeb9 --- /dev/null +++ b/test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/actual.js @@ -0,0 +1,2 @@ +var z = {}; +var { x: { y } = {} } = z; diff --git a/test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/expected.js b/test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/expected.js new file mode 100644 index 0000000000..6a3de508c1 --- /dev/null +++ b/test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/expected.js @@ -0,0 +1,6 @@ +"use strict"; + +var z = {}; +var _z$x = z.x; +_z$x = _z$x === undefined ? {} : _z$x; +var y = _z$x.y;