From fe5b1dc542977157c669bb3ee0267662126eebdd Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 7 Jan 2015 14:10:37 +1100 Subject: [PATCH] add reactCompat default to file opts --- lib/6to5/file.js | 1 + lib/6to5/transformation/transformers/react.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/6to5/file.js b/lib/6to5/file.js index 3d0bf8b4e3..f222387830 100644 --- a/lib/6to5/file.js +++ b/lib/6to5/file.js @@ -48,6 +48,7 @@ File.normaliseOptions = function (opts) { _.defaults(opts, { experimental: false, + reactCompat: false, playground: false, whitespace: true, moduleIds: opts.amdModuleIds || false, diff --git a/lib/6to5/transformation/transformers/react.js b/lib/6to5/transformation/transformers/react.js index b63bae1fad..4b06b04ea3 100644 --- a/lib/6to5/transformation/transformers/react.js +++ b/lib/6to5/transformation/transformers/react.js @@ -42,7 +42,7 @@ var isTag = function(tagName) { exports.XJSOpeningElement = { exit: function (node, parent, file) { - var reactCompat = file.opts && file.opts.reactCompat; + var reactCompat = file.opts.reactCompat; var tagExpr = node.name; var args = []; @@ -123,10 +123,10 @@ exports.XJSOpeningElement = { args ); } + } else { + tagExpr = t.memberExpression(t.identifier("React"), t.identifier("createElement")); + return t.callExpression(tagExpr, args); } - - tagExpr = t.memberExpression(t.identifier("React"), t.identifier("createElement")); - return t.callExpression(tagExpr, args); } };