Skip to content

Commit

Permalink
update type signature for JSX.Element, improve renderToString handlin…
Browse files Browse the repository at this point in the history
…g of array child
  • Loading branch information
LankyMoose committed Apr 19, 2024
1 parent 9c8e6cd commit ec08e2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,13 @@ function renderToString_internal<T extends Record<string, unknown>>(
if (typeof el === "number") return encodeHtmlEntities(el.toString())
if (typeof el === "function")
return renderToString_internal(createElement(el, elProps))
if (el instanceof Array)
return el.map((el) => renderToString_internal(el, el.props)).join("")
if (el instanceof Array) {
let s = ""
for (let i = 0; i < el.length; i++) {
s += renderToString_internal(el[i], parent, elProps)
}
return s
}
if (Signal.isSignal(el)) return encodeHtmlEntities(el.value.toString())

el.parent = parent
Expand Down
2 changes: 2 additions & 0 deletions packages/lib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ declare global {

type ElementKey = string | number
type Element =
| Element[]
| Kaioken.VNode
| string
| number
| null
| boolean
| undefined
| Kaioken.Signal<any>

type ElementAttributes = {
Expand Down

0 comments on commit ec08e2f

Please sign in to comment.