@astrojs/react
Advanced tools
Comparing version 0.0.0-self-closing-children-20231120171409 to 0.0.0-self-closing-children-20231120173528
{ | ||
"name": "@astrojs/react", | ||
"description": "Use React components within Astro", | ||
"version": "0.0.0-self-closing-children-20231120171409", | ||
"version": "0.0.0-self-closing-children-20231120173528", | ||
"type": "module", | ||
@@ -55,3 +55,3 @@ "types": "./dist/index.d.ts", | ||
"mocha": "^10.2.0", | ||
"astro": "0.0.0-self-closing-children-20231120171409", | ||
"astro": "0.0.0-self-closing-children-20231120173528", | ||
"astro-scripts": "0.0.14" | ||
@@ -58,0 +58,0 @@ }, |
@@ -11,3 +11,3 @@ import { parse, DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE } from 'ultrahtml'; | ||
function createReactElementFromNode(node) { | ||
const childVnodes = Array.isArray(node.children) | ||
const childVnodes = Array.isArray(node.children) && node.children.length | ||
? node.children | ||
@@ -21,8 +21,7 @@ .map((child) => createReactElementFromNode(child)) | ||
} else if (node.type === ELEMENT_NODE) { | ||
const children = Array.isArray(node.children) && node.children.length === 0 ? undefined : childVnodes; | ||
const { class: className, ...props } = node.attributes; | ||
return createElement(node.name, { ...props, className, key: `${id}-${key++}` }, children); | ||
return createElement(node.name, { ...props, className, key: `${id}-${key++}` }, childVnodes); | ||
} else if (node.type === TEXT_NODE) { | ||
// 0-length text gets omitted in JSX | ||
return node.value.trim() ? child.value : undefined; | ||
return node.value.trim() ? node.value : undefined; | ||
} | ||
@@ -29,0 +28,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
27433
535