@babel/helper-builder-react-jsx
Advanced tools
Comparing version 7.0.0-beta.5 to 7.0.0-beta.31
@@ -32,2 +32,15 @@ "use strict"; | ||
}; | ||
visitor.JSXFragment = { | ||
exit: function exit(path, file) { | ||
if (opts.compat) { | ||
throw path.buildCodeFrameError("Fragment tags are only supported in React 16 and up."); | ||
} | ||
var callExpr = buildFragmentCall(path, file); | ||
if (callExpr) { | ||
path.replaceWith(t.inherits(callExpr, path.node)); | ||
} | ||
} | ||
}; | ||
return visitor; | ||
@@ -163,2 +176,29 @@ | ||
} | ||
function buildFragmentCall(path, file) { | ||
if (opts.filter && !opts.filter(path.node, file)) return; | ||
var openingPath = path.get("openingElement"); | ||
openingPath.parent.children = t.react.buildChildren(openingPath.parent); | ||
var args = []; | ||
var tagName = null; | ||
var tagExpr = file.get("jsxFragIdentifier")(); | ||
var state = { | ||
tagExpr: tagExpr, | ||
tagName: tagName, | ||
args: args | ||
}; | ||
if (opts.pre) { | ||
opts.pre(state, file); | ||
} | ||
args.push.apply(args, [t.nullLiteral()].concat(path.node.children)); | ||
if (opts.post) { | ||
opts.post(state, file); | ||
} | ||
file.set("usedFragment", true); | ||
return state.call || t.callExpression(state.callee, args); | ||
} | ||
} |
{ | ||
"name": "@babel/helper-builder-react-jsx", | ||
"version": "7.0.0-beta.5", | ||
"version": "7.0.0-beta.31", | ||
"description": "Helper function to build react jsx", | ||
@@ -9,5 +9,5 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-react-jsx", | ||
"dependencies": { | ||
"@babel/types": "7.0.0-beta.5", | ||
"@babel/types": "7.0.0-beta.31", | ||
"esutils": "^2.0.0" | ||
} | ||
} |
@@ -11,4 +11,2 @@ # @babel/helper-builder-react-jsx | ||
call?: Object; // optional call property that can be set to override the call expression returned | ||
pre?: Function; // function called with (state: ElementState) before building attribs | ||
post?: Function; // function called with (state: ElementState) after building attribs | ||
}; | ||
@@ -22,9 +20,11 @@ | ||
pre: function (state: ElementState) { | ||
// called before building the element | ||
// function called with (state: ElementState) before building attribs | ||
}, | ||
post: function (state: ElementState) { | ||
// called after building the element | ||
} | ||
// function called with (state: ElementState) after building attribs | ||
}, | ||
compat?: boolean // true if React is in compat mode | ||
}); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6861
159
+ Added@babel/types@7.0.0-beta.31(transitive)
- Removed@babel/types@7.0.0-beta.5(transitive)
Updated@babel/types@7.0.0-beta.31