MCPcopy
hub / github.com/vercel/next.js / reactElementToDOM

Function reactElementToDOM

packages/next/src/client/head-manager.ts:5–21  ·  view source on GitHub ↗
({ type, props }: JSX.Element)

Source from the content-addressed store, hash-verified

3import type { JSX } from 'react'
4
5function 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

Callers 1

updateElementsFunction · 0.85

Calls 3

setAttributesFromPropsFunction · 0.90
isArrayMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected