Comparing version 0.12.4 to 0.12.5
# buble changelog | ||
## 0.12.5 | ||
* Prevent reserved words being used as identifiers ([#86](https://gitlab.com/Rich-Harris/buble/issues/86)) | ||
* Use correct `this` when transpiling `super` inside arrow function ([#89](https://gitlab.com/Rich-Harris/buble/issues/89)) | ||
* Handle body-less `for-of` loops ([#80](https://gitlab.com/Rich-Harris/buble/issues/80)) | ||
## 0.12.4 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "buble", | ||
"version": "0.12.4", | ||
"version": "0.12.5", | ||
"description": "The blazing fast, batteries-included ES2015 compiler", | ||
@@ -5,0 +5,0 @@ "main": "dist/buble.umd.js", |
import Node from '../Node.js'; | ||
import { findIndex } from '../../utils/array.js'; | ||
import reserved from '../../utils/reserved.js'; | ||
@@ -82,3 +83,3 @@ // TODO this code is pretty wild, tidy it up | ||
let methodName = method.key.name; | ||
if ( scope.contains( methodName ) ) methodName = scope.createIdentifier( methodName ); | ||
if ( scope.contains( methodName ) || reserved[ methodName ] ) methodName = scope.createIdentifier( methodName ); | ||
@@ -85,0 +86,0 @@ if ( isAccessor ) { |
@@ -16,2 +16,15 @@ import LoopStatement from './shared/LoopStatement.js'; | ||
// edge case (#80) | ||
if ( !this.body.body[0] ) { | ||
if ( this.left.type === 'VariableDeclaration' && this.left.kind === 'var' ) { | ||
code.remove( this.start, this.left.start ); | ||
code.insertLeft( this.left.end, ';' ); | ||
code.remove( this.left.end, this.end ); | ||
} else { | ||
code.remove( this.start, this.end ); | ||
} | ||
return; | ||
} | ||
const scope = this.findScope( true ); | ||
@@ -18,0 +31,0 @@ const i0 = this.getIndentation(); |
@@ -27,2 +27,16 @@ import Node from '../Node.js'; | ||
} | ||
if ( transforms.arrow ) { | ||
const lexicalBoundary = this.findLexicalBoundary(); | ||
const arrowFunction = this.findNearest( 'ArrowFunctionExpression' ); | ||
const loop = this.findNearest( /(?:For(?:In|Of)?|While)Statement/ ); | ||
if ( arrowFunction && arrowFunction.depth > lexicalBoundary.depth ) { | ||
this.thisAlias = lexicalBoundary.getThisAlias(); | ||
} | ||
if ( loop && loop.body.contains( this ) && loop.depth > lexicalBoundary.depth ) { | ||
this.thisAlias = lexicalBoundary.getThisAlias(); | ||
} | ||
} | ||
} | ||
@@ -45,6 +59,8 @@ | ||
const thisAlias = this.thisAlias || 'this'; | ||
if ( callExpression.arguments.length ) { | ||
code.insertLeft( callExpression.arguments[0].start, `this, ` ); | ||
code.insertLeft( callExpression.arguments[0].start, `${thisAlias}, ` ); | ||
} else { | ||
code.insertLeft( callExpression.end - 1, `this` ); | ||
code.insertLeft( callExpression.end - 1, `${thisAlias}` ); | ||
} | ||
@@ -51,0 +67,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3237476
32657
15