false/null = no attr

This commit is contained in:
Chris Wanstrath 2025-11-05 15:46:25 -08:00
parent 56de9709e9
commit 6114e5cf5e

View File

@ -77,10 +77,11 @@ const tagBlock = async (tagName: string, props = {}, fn: Function) => {
} }
const tagCall = (tagName: string, atNamed = {}, ...args: any[]) => { const tagCall = (tagName: string, atNamed = {}, ...args: any[]) => {
console.log('tagCall:', { tagName, atNamed, args })
args = args.map(arg => typeof arg === 'function' ? arg.tagName : arg) args = args.map(arg => typeof arg === 'function' ? arg.tagName : arg)
const attrs = Object.entries(atNamed).map(([key, value]) => `${key}="${typeof value === 'function' ? (value as any).tagName : value}"`) const attrs = Object.entries(atNamed)
.filter(([key, value]) => value)
.map(([key, value]) => `${key}="${typeof value === 'function' ? (value as any).tagName : value}"`)
const space = attrs.length ? ' ' : '' const space = attrs.length ? ' ' : ''
const children = args const children = args
.reverse() .reverse()