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 4.3.1 to 4.3.3

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [4.3.3](https://github.com/smooth-code/svgr/tree/master/packages/babel-plugin-svg-dynamic-title/compare/v4.3.2...v4.3.3) (2019-09-24)
### Bug Fixes
* **babel-plugin-svg-dynamic-title:** dont render empty title ([#341](https://github.com/smooth-code/svgr/tree/master/packages/babel-plugin-svg-dynamic-title/issues/341)) ([88b24c5](https://github.com/smooth-code/svgr/tree/master/packages/babel-plugin-svg-dynamic-title/commit/88b24c5)), closes [#333](https://github.com/smooth-code/svgr/tree/master/packages/babel-plugin-svg-dynamic-title/issues/333)
## [4.3.1](https://github.com/smooth-code/svgr/tree/master/packages/babel-plugin-svg-dynamic-title/compare/v4.3.0...v4.3.1) (2019-07-01)

@@ -8,0 +19,0 @@

16

lib/index.js

@@ -18,17 +18,19 @@ "use strict";

function createTitle(children = []) {
return t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier('title'), []), t.jsxClosingElement(t.jsxIdentifier('title')), children);
function createTitle(children = [], attributes = []) {
return t.jsxElement(t.jsxOpeningElement(t.jsxIdentifier('title'), attributes), t.jsxClosingElement(t.jsxIdentifier('title')), children);
}
function getTitleElement(existingTitleChildren = []) {
function getTitleElement(existingTitle) {
const titleExpression = t.identifier('title');
let titleElement = createTitle([t.jsxExpressionContainer(titleExpression)]);
let titleElement = t.conditionalExpression(titleExpression, createTitle([t.jsxExpressionContainer(titleExpression)], existingTitle ? existingTitle.openingElement.attributes : []), t.nullLiteral());
if (existingTitleChildren && existingTitleChildren.length) {
if (existingTitle && existingTitle.children && existingTitle.children.length) {
// if title already exists
// render as follows
const fallbackTitleElement = createTitle(existingTitleChildren); // {title === undefined ? fallbackTitleElement : titleElement}
const fallbackTitleElement = existingTitle; // {title === undefined ? fallbackTitleElement : titleElement}
const conditionalExpressionForTitle = t.conditionalExpression(t.binaryExpression('===', titleExpression, t.identifier('undefined')), fallbackTitleElement, titleElement);
titleElement = t.jsxExpressionContainer(conditionalExpressionForTitle);
} else {
titleElement = t.jsxExpressionContainer(titleElement);
}

@@ -45,3 +47,3 @@

if (childPath.node.openingElement.name.name !== 'title') return false;
titleElement = getTitleElement(childPath.node.children);
titleElement = getTitleElement(childPath.node);
childPath.replaceWith(titleElement);

@@ -48,0 +50,0 @@ return true;

{
"name": "@svgr/babel-plugin-svg-dynamic-title",
"description": "Transform SVG by adding a dynamic title element",
"version": "4.3.1",
"version": "4.3.3",
"main": "lib/index.js",

@@ -23,3 +23,3 @@ "repository": "https://github.com/smooth-code/svgr/tree/master/packages/babel-plugin-svg-dynamic-title",

},
"gitHead": "06e1e996a92289183fca0aabe4ba286e3a227f1b"
"gitHead": "14a26644e7bda24c2ff97524f3d8841801a6442f"
}
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