This commit is contained in:
Chris Wanstrath 2025-11-05 15:45:10 -08:00
parent c7fed4bac6
commit 201cba6542

View File

@ -56,6 +56,7 @@ for (const name of HTML5_TAGS) {
(ribbitGlobals as any)[name] = (atNamed: {}, ...args: any[]) => tag(name, atNamed, ...args)
; (ribbitGlobals as any)[name].tagName = name
}
; (ribbitGlobals as any)['text'].tagName = 'text'
const tag = async (tagName: string, atNamed = {}, ...args: any[]) => {
if (typeof args[0] === 'function')
@ -76,9 +77,10 @@ const tagBlock = async (tagName: string, props = {}, fn: Function) => {
}
const tagCall = (tagName: string, atNamed = {}, ...args: any[]) => {
console.log('tagCall:', { tagName, atNamed, args })
args = args.map(arg => typeof arg === 'function' ? arg.tagName : arg)
const attrs = Object.entries(atNamed).map(([key, value]) => `${key}="${value}"`)
const attrs = Object.entries(atNamed).map(([key, value]) => `${key}="${typeof value === 'function' ? (value as any).tagName : value}"`)
const space = attrs.length ? ' ' : ''
const children = args
.reverse()