node.astro 744 Bytes
---
import { ELEMENT_NODE, TEXT_NODE } from 'ultrahtml'
import Children from './children.astro'

const { props: { parent = null, node, index = 0, debug = false, replacers, slotHandler } } = Astro
const { name: Name, attributes } = node

if (debug) {
  console.log('Node.astro:debug', {node})
}
---
{
  node.type === TEXT_NODE ? <Fragment set:html={node.value}/>
  : node.type === ELEMENT_NODE ? (
    node.isSelfClosingTag ? <Name {...attributes}/>
    : <Name {...attributes}>
        <Children parent={node} children={node.children} debug={debug} replacers={replacers} slotHandler={slotHandler}/>
      </Name>
  ) : (
    <Children parent={node} children={node.children} debug={debug} replacers={replacers} slotHandler={slotHandler}/>
  )
}