Socket
Socket
Sign inDemoInstall

hast-util-to-estree

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hast-util-to-estree - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

25

index.js

@@ -6,2 +6,3 @@ 'use strict'

var commas = require('comma-separated-tokens')
var whitespace = require('hast-util-whitespace')
var find = require('property-information/find')

@@ -273,3 +274,25 @@ var hastToReact = require('property-information/hast-to-react.json')

function root(node, context) {
return createJsxFragment(node, all(node, context))
var children = all(node, context)
var cleanChildren = []
var index = -1
var queue
// Remove surrounding whitespace nodes from the fragment.
while (++index < children.length) {
if (
children[index].type === 'JSXExpressionContainer' &&
children[index].expression.type === 'Literal' &&
whitespace(children[index].expression.value)
) {
if (queue) {
queue.push(children[index])
}
} else {
push.apply(cleanChildren, queue)
cleanChildren.push(children[index])
queue = []
}
}
return createJsxFragment(node, cleanChildren)
}

@@ -276,0 +299,0 @@

3

package.json
{
"name": "hast-util-to-estree",
"version": "1.0.2",
"version": "1.0.3",
"description": "hast utility to transform to estree (JavaScript AST) JSX",

@@ -38,2 +38,3 @@ "license": "MIT",

"comma-separated-tokens": "^1.0.0",
"hast-util-whitespace": "^1.0.0",
"property-information": "^5.0.0",

@@ -40,0 +41,0 @@ "space-separated-tokens": "^1.0.0",

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