hast-util-to-estree
Advanced tools
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 @@ |
{ | ||
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20029
363
7
+ Addedhast-util-whitespace@^1.0.0
+ Addedhast-util-whitespace@1.0.4(transitive)