From 69f2a0d3f1fd72625e2e7d630360f2d5e19e688d Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 28 Jan 2015 20:01:55 +1100 Subject: [PATCH] better t.toIdentifier behaviour that doesn't camelcase on underscores - fixes #610 --- lib/6to5/types/index.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index a1e1135290..8d56f4aa2d 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -226,7 +226,7 @@ t.prependToMemberExpression = function (member, append) { }; /** - * Description + * Check if the input `node` is going to be evaluated, ie. is a refernece. * * @param {Object} node * @param {Object} parent @@ -331,13 +331,10 @@ t.toIdentifier = function (name) { name = name.replace(/^[-0-9]+/, ""); // camel case - name = name.replace(/[-_\s]+(.)?/g, function (match, c) { + name = name.replace(/[-\s]+(.)?/g, function (match, c) { return c ? c.toUpperCase() : ""; }); - // remove underscores from start of name - name = name.replace(/^\_/, ""); - if (!t.isValidIdentifier(name)) { name = "_" + name; }