( component: DevComponent, indentLevel = 0, isInline?: (tag: string) => boolean )
| 362 | } |
| 363 | |
| 364 | function stringifyJSXComponent( |
| 365 | component: DevComponent, |
| 366 | indentLevel = 0, |
| 367 | isInline?: (tag: string) => boolean |
| 368 | ) { |
| 369 | return stringifyBaseComponent( |
| 370 | component, |
| 371 | (key, value) => { |
| 372 | if (EVENT_HANDLER_RE.test(key)) { |
| 373 | const callback = typeof value === 'string' ? value : '() => {}' |
| 374 | return `${key}="{${callback.trim()}}"` |
| 375 | } |
| 376 | |
| 377 | if (typeof value === 'string') { |
| 378 | return `${key}="${escapeHTML(value).trim()}"` |
| 379 | } |
| 380 | |
| 381 | if (typeof value === 'boolean') { |
| 382 | return value ? key : `${key}={false}` |
| 383 | } |
| 384 | |
| 385 | if (typeof value === 'object' && value != null) { |
| 386 | const pruned = prune(value) |
| 387 | if (pruned == null) { |
| 388 | return '' |
| 389 | } |
| 390 | return `${key}={${stringify(pruned)}}` |
| 391 | } |
| 392 | |
| 393 | return `${key}={${stringify(value)}}` |
| 394 | }, |
| 395 | indentLevel, |
| 396 | isInline |
| 397 | ) |
| 398 | } |
| 399 | |
| 400 | type SerializeOptions = { |
| 401 | lang?: SupportedLang |
no test coverage detected