Skip to content

Commit

Permalink
add JSXAttribute visitor function, wraps JSXElement attributes in a J…
Browse files Browse the repository at this point in the history
…SXExpressionContainer; also adds test fixtures
  • Loading branch information
noahlemen committed Jul 25, 2017
1 parent 19c4dd2 commit 0a3b8de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/babel-plugin-transform-react-jsx/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export default function({ types: t }) {
);
};

visitor.JSXAttribute = function(path) {
if (t.isJSXElement(path.node.value)) {
path.node.value = t.jSXExpressionContainer(path.node.value);
}
};

return {
inherits: jsx,
visitor,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div attr=<div /> />
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
React.createElement("div", {
attr: React.createElement("div", null)
});

0 comments on commit 0a3b8de

Please sign in to comment.