({ type, props }: JSX.Element)
| 3 | import type { JSX } from 'react' |
| 4 | |
| 5 | function reactElementToDOM({ type, props }: JSX.Element): HTMLElement { |
| 6 | const el: HTMLElement = document.createElement(type) |
| 7 | setAttributesFromProps(el, props) |
| 8 | |
| 9 | const { children, dangerouslySetInnerHTML } = props |
| 10 | if (dangerouslySetInnerHTML) { |
| 11 | el.innerHTML = dangerouslySetInnerHTML.__html || '' |
| 12 | } else if (children) { |
| 13 | el.textContent = |
| 14 | typeof children === 'string' |
| 15 | ? children |
| 16 | : Array.isArray(children) |
| 17 | ? children.join('') |
| 18 | : '' |
| 19 | } |
| 20 | return el |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * When a `nonce` is present on an element, browsers such as Chrome and Firefox strip it out of the |
no test coverage detected