diff --git a/lib/6to5/generation/node/index.js b/lib/6to5/generation/node/index.js index 470fe00f24..240036513e 100644 --- a/lib/6to5/generation/node/index.js +++ b/lib/6to5/generation/node/index.js @@ -54,10 +54,7 @@ Node.prototype.needsWhitespace = function (type) { lines = Node.needsWhitespace(expr, node, type); if (lines) return false; }); - if (lines) return lines; - - var opts = whitespace.static[node.type]; - return (opts && opts[type]) || 0; + return lines || 0; }; Node.prototype.needsWhitespaceBefore = function () { diff --git a/lib/6to5/generation/node/whitespace.js b/lib/6to5/generation/node/whitespace.js index cc44070ec6..9d9ce770f7 100644 --- a/lib/6to5/generation/node/whitespace.js +++ b/lib/6to5/generation/node/whitespace.js @@ -1,25 +1,6 @@ var _ = require("lodash"); var t = require("../../types"); -exports.static = { - FunctionExpression: 1, - FunctionStatement: 1, - ClassExpression: 1, - ClassStatement: 1, - ForOfStatement: 1, - ForInStatement: 1, - ForStatement: 1, - SwitchStatement: 1, - IfStatement: { before: 1 }, - CallExpression: { after: 1 }, - Literal: { after: 1 } -}; - -_.each(exports.static, function (amounts, type) { - if (_.isNumber(amounts)) amounts = { after: amounts, before: amounts }; - exports.static[type] = amounts; -}); - exports.before = { nodes: { Property: function (node, parent) { @@ -43,6 +24,8 @@ exports.before = { }; exports.after = { + nodes: {}, + list: { VariableDeclaration: function (node) { return _.map(node.declarations, "init");; @@ -57,3 +40,21 @@ exports.after = { } } }; + +_.each({ + Function: 1, + Class: 1, + For: 1, + SwitchStatement: 1, + IfStatement: { before: 1 }, + CallExpression: { after: 1 }, + Literal: { after: 1 } +}, function (amounts, type) { + if (_.isNumber(amounts)) amounts = { after: amounts, before: amounts }; + + _.each(amounts, function (amount, key) { + exports[key].nodes[type] = function () { + return amount; + }; + }); +});