Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Commit

Permalink
Fixing false positive regression on Function Declarations from previo…
Browse files Browse the repository at this point in the history
…us changes. This change adds a reset to the foundJSXKey to prevent false positives
  • Loading branch information
Josh Black committed Oct 9, 2015
1 parent e2aa5fa commit d13c8d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ export default function ({ Plugin, types: t }) {
return;
}

this.state[foundJSXKey] = false;

// No-op for `render` methods in this visitor
if (parent.key && parent.key.name === 'render') {
return;
Expand Down Expand Up @@ -342,6 +344,10 @@ export default function ({ Plugin, types: t }) {
);
}

if (t.isFunctionDeclaration(node)) {
// console.log(node.body.body.filter(t.isReturnStatement));
}

return [
node,
t.assignmentExpression('=', bindingId,
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/pure-function/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ exports.NamedExportFunction = NamedExportFunction = _wrapComponent('_$NamedExpor
function DefaultExportFunction() {
return _react2['default'].createElement('div', null);
}

DefaultExportFunction = _wrapComponent('_$DefaultExportFunction')(DefaultExportFunction)
var ModulePattern = {
NoProps: _wrapComponent('_$NoProps')(function () {
Expand Down

1 comment on commit d13c8d3

@joshblack
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a reset to the foundJSXKey state in order to fix regressions introduced by adding support for the export and module pattern edge cases.

Please sign in to comment.