0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

[ci] format

This commit is contained in:
Arsh 2023-11-21 17:21:41 +00:00 committed by astrobot-houston
parent af43fb5172
commit 4aca47beca
2 changed files with 15 additions and 16 deletions

View file

@ -1,15 +1,15 @@
import { expect } from 'chai';
import convert from "../vnode-children.js";
import convert from '../vnode-children.js';
describe('experimental react children', () => {
it('has undefined as children for direct children', () => {
const [ imgVNode ] = convert('<img src="abc"></img>');
expect(imgVNode.props).to.deep.include({ children: undefined });
})
it('has undefined as children for direct children', () => {
const [imgVNode] = convert('<img src="abc"></img>');
expect(imgVNode.props).to.deep.include({ children: undefined });
});
it('has undefined as children for nested children', () => {
const [ divVNode ] = convert('<div><img src="xyz"></img></div>');
const [ imgVNode ] = divVNode.props.children;
expect(imgVNode.props).to.deep.include({ children: undefined });
})
})
it('has undefined as children for nested children', () => {
const [divVNode] = convert('<div><img src="xyz"></img></div>');
const [imgVNode] = divVNode.props.children;
expect(imgVNode.props).to.deep.include({ children: undefined });
});
});

View file

@ -8,11 +8,10 @@ export default function convert(children) {
let key = 0;
function createReactElementFromNode(node) {
const childVnodes = Array.isArray(node.children) && node.children.length
? node.children
.map((child) => createReactElementFromNode(child))
.filter(Boolean)
: undefined;
const childVnodes =
Array.isArray(node.children) && node.children.length
? node.children.map((child) => createReactElementFromNode(child)).filter(Boolean)
: undefined;
if (node.type === DOCUMENT_NODE) {
return createElement(Fragment, {}, childVnodes);