Browse Source

Merge pull request #983 from btd/master

Do not skip non empty block statements
legacy-quote-reserved-properties
Rich Harris 8 years ago
committed by GitHub
parent
commit
025249ff1d
  1. 10
      src/ast/nodes/BlockStatement.js
  2. 3
      test/form/non-empty-block-statement/_config.js
  3. 9
      test/form/non-empty-block-statement/_expected/amd.js
  4. 7
      test/form/non-empty-block-statement/_expected/cjs.js
  5. 5
      test/form/non-empty-block-statement/_expected/es.js
  6. 10
      test/form/non-empty-block-statement/_expected/iife.js
  7. 13
      test/form/non-empty-block-statement/_expected/umd.js
  8. 5
      test/form/non-empty-block-statement/main.js

10
src/ast/nodes/BlockStatement.js

@ -46,4 +46,14 @@ export default class BlockStatement extends Statement {
lastNode = node; lastNode = node;
} }
} }
render ( code, es ) {
if (this.body.length) {
for ( const node of this.body ) {
node.render( code, es );
}
} else {
Statement.prototype.render.call(this, code, es);
}
}
} }

3
test/form/non-empty-block-statement/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'do not remove non an empty block statement'
};

9
test/form/non-empty-block-statement/_expected/amd.js

@ -0,0 +1,9 @@
define(function () { 'use strict';
console.log( 1 );
{
var tmp = 10;
}
console.log( tmp );
});

7
test/form/non-empty-block-statement/_expected/cjs.js

@ -0,0 +1,7 @@
'use strict';
console.log( 1 );
{
var tmp = 10;
}
console.log( tmp );

5
test/form/non-empty-block-statement/_expected/es.js

@ -0,0 +1,5 @@
console.log( 1 );
{
var tmp = 10;
}
console.log( tmp );

10
test/form/non-empty-block-statement/_expected/iife.js

@ -0,0 +1,10 @@
(function () {
'use strict';
console.log( 1 );
{
var tmp = 10;
}
console.log( tmp );
}());

13
test/form/non-empty-block-statement/_expected/umd.js

@ -0,0 +1,13 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
console.log( 1 );
{
var tmp = 10;
}
console.log( tmp );
})));

5
test/form/non-empty-block-statement/main.js

@ -0,0 +1,5 @@
console.log( 1 );
{
var tmp = 10;
}
console.log( tmp );
Loading…
Cancel
Save