| 556 | } |
| 557 | |
| 558 | const pushChild = <Msg>( |
| 559 | out: Array<Node<Msg, any>>, |
| 560 | input: Content<Msg, any> | string | false | null | undefined |
| 561 | ): void => { |
| 562 | if (input === false || input === null || input === undefined) return |
| 563 | if (typeof input === "string") { |
| 564 | if (input === "") return |
| 565 | const last = out.length === 0 ? undefined : out[out.length - 1] |
| 566 | if (last !== undefined && last._tag === "Text") { |
| 567 | out[out.length - 1] = text(last.text + input) |
| 568 | } else out.push(text(input)) |
| 569 | return |
| 570 | } |
| 571 | const node: Node<Msg, any> = toNode(input) |
| 572 | if (node._tag === "Text") { |
| 573 | if (node.text === "") return |
| 574 | const last = out.length === 0 ? undefined : out[out.length - 1] |
| 575 | if (last !== undefined && last._tag === "Text") { |
| 576 | out[out.length - 1] = text(last.text + node.text) |
| 577 | return |
| 578 | } |
| 579 | } |
| 580 | out.push(node) |
| 581 | } |
| 582 | |
| 583 | /** |
| 584 | * Whether a value is an element builder. |