Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/helper-builder-react-jsx

Package Overview
Dependencies
Maintainers
6
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-builder-react-jsx - npm Package Compare versions

Comparing version 7.14.5 to 7.15.4

100

lib/index.js

@@ -8,6 +8,32 @@ "use strict";

var t = require("@babel/types");
var _t = require("@babel/types");
var _helperAnnotateAsPure = require("@babel/helper-annotate-as-pure");
const {
booleanLiteral,
callExpression,
identifier,
inherits,
isIdentifier,
isJSXExpressionContainer,
isJSXIdentifier,
isJSXMemberExpression,
isJSXNamespacedName,
isJSXSpreadAttribute,
isLiteral,
isObjectExpression,
isReferenced,
isStringLiteral,
isValidIdentifier,
memberExpression,
nullLiteral,
objectExpression,
objectProperty,
react,
spreadElement,
stringLiteral,
thisExpression
} = _t;
function _default(opts) {

@@ -32,3 +58,3 @@ const visitor = {};

if (callExpr) {
path.replaceWith(t.inherits(callExpr, path.node));
path.replaceWith(inherits(callExpr, path.node));
}

@@ -47,3 +73,3 @@ }

if (callExpr) {
path.replaceWith(t.inherits(callExpr, path.node));
path.replaceWith(inherits(callExpr, path.node));
}

@@ -56,14 +82,14 @@ }

function convertJSXIdentifier(node, parent) {
if (t.isJSXIdentifier(node)) {
if (node.name === "this" && t.isReferenced(node, parent)) {
return t.thisExpression();
} else if (t.isValidIdentifier(node.name, false)) {
if (isJSXIdentifier(node)) {
if (node.name === "this" && isReferenced(node, parent)) {
return thisExpression();
} else if (isValidIdentifier(node.name, false)) {
node.type = "Identifier";
} else {
return t.stringLiteral(node.name);
return stringLiteral(node.name);
}
} else if (t.isJSXMemberExpression(node)) {
return t.memberExpression(convertJSXIdentifier(node.object, node), convertJSXIdentifier(node.property, node));
} else if (t.isJSXNamespacedName(node)) {
return t.stringLiteral(`${node.namespace.name}:${node.name.name}`);
} else if (isJSXMemberExpression(node)) {
return memberExpression(convertJSXIdentifier(node.object, node), convertJSXIdentifier(node.property, node));
} else if (isJSXNamespacedName(node)) {
return stringLiteral(`${node.namespace.name}:${node.name.name}`);
}

@@ -75,3 +101,3 @@

function convertAttributeValue(node) {
if (t.isJSXExpressionContainer(node)) {
if (isJSXExpressionContainer(node)) {
return node.expression;

@@ -84,9 +110,9 @@ } else {

function convertAttribute(node) {
const value = convertAttributeValue(node.value || t.booleanLiteral(true));
const value = convertAttributeValue(node.value || booleanLiteral(true));
if (t.isJSXSpreadAttribute(node)) {
return t.spreadElement(node.argument);
if (isJSXSpreadAttribute(node)) {
return spreadElement(node.argument);
}
if (t.isStringLiteral(value) && !t.isJSXExpressionContainer(node.value)) {
if (isStringLiteral(value) && !isJSXExpressionContainer(node.value)) {
var _value$extra;

@@ -98,11 +124,11 @@

if (t.isJSXNamespacedName(node.name)) {
node.name = t.stringLiteral(node.name.namespace.name + ":" + node.name.name.name);
} else if (t.isValidIdentifier(node.name.name, false)) {
if (isJSXNamespacedName(node.name)) {
node.name = stringLiteral(node.name.namespace.name + ":" + node.name.name.name);
} else if (isValidIdentifier(node.name.name, false)) {
node.name.type = "Identifier";
} else {
node.name = t.stringLiteral(node.name.name);
node.name = stringLiteral(node.name.name);
}
return t.inherits(t.objectProperty(node.name, value), node);
return inherits(objectProperty(node.name, value), node);
}

@@ -113,3 +139,3 @@

const openingPath = path.get("openingElement");
openingPath.parent.children = t.react.buildChildren(openingPath.parent);
openingPath.parent.children = react.buildChildren(openingPath.parent);
const tagExpr = convertJSXIdentifier(openingPath.node.name, openingPath.node);

@@ -119,5 +145,5 @@ const args = [];

if (t.isIdentifier(tagExpr)) {
if (isIdentifier(tagExpr)) {
tagName = tagExpr.name;
} else if (t.isLiteral(tagExpr)) {
} else if (isLiteral(tagExpr)) {
tagName = tagExpr.value;

@@ -144,3 +170,3 @@ }

} else {
attribs = t.nullLiteral();
attribs = nullLiteral();
}

@@ -154,3 +180,3 @@

const call = state.call || t.callExpression(state.callee, args);
const call = state.call || callExpression(state.callee, args);
if (state.pure) (0, _helperAnnotateAsPure.default)(call);

@@ -162,3 +188,3 @@ return call;

if (!_props.length) return _props;
objs.push(t.objectExpression(_props));
objs.push(objectExpression(_props));
return [];

@@ -190,3 +216,3 @@ }

const props = attribs.map(convertAttribute);
return t.objectExpression(props);
return objectExpression(props);
}

@@ -197,3 +223,3 @@

if (t.isJSXSpreadAttribute(prop)) {
if (isJSXSpreadAttribute(prop)) {
_props = pushProps(_props, objs);

@@ -211,8 +237,8 @@ objs.push(prop.argument);

} else {
if (!t.isObjectExpression(objs[0])) {
objs.unshift(t.objectExpression([]));
if (!isObjectExpression(objs[0])) {
objs.unshift(objectExpression([]));
}
const helper = useBuiltIns ? t.memberExpression(t.identifier("Object"), t.identifier("assign")) : file.addHelper("extends");
attribs = t.callExpression(helper, objs);
const helper = useBuiltIns ? memberExpression(identifier("Object"), identifier("assign")) : file.addHelper("extends");
attribs = callExpression(helper, objs);
}

@@ -226,3 +252,3 @@

const openingPath = path.get("openingElement");
openingPath.parent.children = t.react.buildChildren(openingPath.parent);
openingPath.parent.children = react.buildChildren(openingPath.parent);
const args = [];

@@ -242,3 +268,3 @@ const tagName = null;

args.push(t.nullLiteral(), ...path.node.children);
args.push(nullLiteral(), ...path.node.children);

@@ -250,3 +276,3 @@ if (opts.post) {

file.set("usedFragment", true);
const call = state.call || t.callExpression(state.callee, args);
const call = state.call || callExpression(state.callee, args);
if (state.pure) (0, _helperAnnotateAsPure.default)(call);

@@ -253,0 +279,0 @@ return call;

{
"name": "@babel/helper-builder-react-jsx",
"version": "7.14.5",
"version": "7.15.4",
"description": "Helper function to build react jsx",

@@ -17,4 +17,4 @@ "repository": {

"dependencies": {
"@babel/helper-annotate-as-pure": "^7.14.5",
"@babel/types": "^7.14.5"
"@babel/helper-annotate-as-pure": "^7.15.4",
"@babel/types": "^7.15.4"
},

@@ -21,0 +21,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc