🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

babel-plugin-react-v-html

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-react-v-html - npm Package Compare versions

Comparing version
1.0.1
to
1.0.3
+1
-1
package.json
{
"name": "babel-plugin-react-v-html",
"version": "1.0.1",
"version": "1.0.3",
"description": "Babel plugin for React component to transform the JSXAttribute from v-html to dangerouslySetInnerHTML.",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -1,8 +0,7 @@

module.exports = ({ types: babelTypes }) => ({
module.exports = ({
types: babelTypes
}) => ({
visitor: {
JSXIdentifier(path) {
const name = path.node.name;
if (name === 'v-html') {
path.node.name = 'dangerouslySetInnerHTML';
if (path.node.name === 'v-html') {
const {

@@ -12,13 +11,23 @@ JSXExpressionContainer,

ObjectProperty,
StringLiteral
} = babelTypes;
StringLiteral,
JSXIdentifier
} = babelTypes
path.container.value = JSXExpressionContainer(
ObjectExpression([
ObjectProperty(
StringLiteral('__html'),
path.container.value.expression,
)
])
path.replaceWith(
JSXIdentifier('dangerouslySetInnerHTML')
)
const htmlContainer = path.parentPath.get('value'),
html = htmlContainer.get('expression')
htmlContainer.replaceWith(
JSXExpressionContainer(
ObjectExpression([
ObjectProperty(
StringLiteral('__html'),
html.node
)
])
)
)
}

@@ -25,0 +34,0 @@ }