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

@svgr/babel-plugin-svg-dynamic-title

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svgr/babel-plugin-svg-dynamic-title - npm Package Compare versions

Comparing version 6.5.0 to 6.5.1

50

dist/index.js

@@ -8,11 +8,22 @@ 'use strict';

const eleName = core.types.jsxIdentifier(tag);
return core.types.jsxElement(core.types.jsxOpeningElement(eleName, attributes), core.types.jsxClosingElement(eleName), children);
return core.types.jsxElement(
core.types.jsxOpeningElement(eleName, attributes),
core.types.jsxClosingElement(eleName),
children
);
};
const createTagIdAttribute = (tag) => core.types.jsxAttribute(core.types.jsxIdentifier("id"), core.types.jsxExpressionContainer(core.types.identifier(`${tag}Id`)));
const createTagIdAttribute = (tag) => core.types.jsxAttribute(
core.types.jsxIdentifier("id"),
core.types.jsxExpressionContainer(core.types.identifier(`${tag}Id`))
);
const addTagIdAttribute = (tag, attributes) => {
const existingId = attributes.find((attribute) => core.types.isJSXAttribute(attribute) && attribute.name.name === "id");
const existingId = attributes.find(
(attribute) => core.types.isJSXAttribute(attribute) && attribute.name.name === "id"
);
if (!existingId) {
return [...attributes, createTagIdAttribute(tag)];
}
existingId.value = core.types.jsxExpressionContainer(core.types.isStringLiteral(existingId.value) ? core.types.logicalExpression("||", core.types.identifier(`${tag}Id`), existingId.value) : core.types.identifier(`${tag}Id`));
existingId.value = core.types.jsxExpressionContainer(
core.types.isStringLiteral(existingId.value) ? core.types.logicalExpression("||", core.types.identifier(`${tag}Id`), existingId.value) : core.types.identifier(`${tag}Id`)
);
return attributes;

@@ -28,3 +39,5 @@ };

const openingElementName = openingElement.get("name");
if (!elements.some((element) => openingElementName.isJSXIdentifier({ name: element }))) {
if (!elements.some(
(element) => openingElementName.isJSXIdentifier({ name: element })
)) {
return;

@@ -36,7 +49,28 @@ }

if (existingTitle) {
existingTitle.openingElement.attributes = addTagIdAttribute(tag, existingTitle.openingElement.attributes);
existingTitle.openingElement.attributes = addTagIdAttribute(
tag,
existingTitle.openingElement.attributes
);
}
const conditionalTitle = core.types.conditionalExpression(tagExpression, createTagElement(tag, [core.types.jsxExpressionContainer(tagExpression)], existingTitle ? existingTitle.openingElement.attributes : [createTagIdAttribute(tag)]), core.types.nullLiteral());
const conditionalTitle = core.types.conditionalExpression(
tagExpression,
createTagElement(
tag,
[core.types.jsxExpressionContainer(tagExpression)],
existingTitle ? existingTitle.openingElement.attributes : [createTagIdAttribute(tag)]
),
core.types.nullLiteral()
);
if ((_a = existingTitle == null ? void 0 : existingTitle.children) == null ? void 0 : _a.length) {
return core.types.jsxExpressionContainer(core.types.conditionalExpression(core.types.binaryExpression("===", tagExpression, core.types.identifier("undefined")), existingTitle, conditionalTitle));
return core.types.jsxExpressionContainer(
core.types.conditionalExpression(
core.types.binaryExpression(
"===",
tagExpression,
core.types.identifier("undefined")
),
existingTitle,
conditionalTitle
)
);
}

@@ -43,0 +77,0 @@ return core.types.jsxExpressionContainer(conditionalTitle);

4

package.json
{
"name": "@svgr/babel-plugin-svg-dynamic-title",
"description": "Transform SVG by adding a dynamic title element",
"version": "6.5.0",
"version": "6.5.1",
"main": "./dist/index.js",

@@ -39,3 +39,3 @@ "types": "./dist/index.d.ts",

},
"gitHead": "b385279d27e51d34e4684dda326aa4216a485572"
"gitHead": "d5efedd372999692f84d30072e502b5a6b8fe734"
}

Sorry, the diff of this file is not supported yet

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