MCPcopy
hub / github.com/QwikDev/qwik / render

Function render

packages/qwik/src/core/render/dom/render.public.ts:47–85  ·  view source on GitHub ↗
(
  parent: Element | Document,
  jsxOutput: JSXOutput | FunctionComponent<any>,
  opts?: RenderOptions
)

Source from the content-addressed store, hash-verified

45 * @public
46 */
47export const render = async (
48 parent: Element | Document,
49 jsxOutput: JSXOutput | FunctionComponent<any>,
50 opts?: RenderOptions
51): Promise<RenderResult> => {
52 // If input is a component, convert it
53 if (typeof jsxOutput === 'function') {
54 jsxOutput = jsx(jsxOutput, null);
55 }
56 const doc = getDocument(parent);
57 const containerEl = getElement(parent);
58 if (qDev && containerEl.hasAttribute(QContainerAttr)) {
59 throw qError(QError_cannotRenderOverExistingContainer, containerEl);
60 }
61 // if (qDev) {
62 // if (parent.childNodes.length > 0) {
63 // throw new Error('Container must be empty before mounting anything inside');
64 // }
65 // }
66 injectQContainer(containerEl);
67
68 const containerState = _getContainerState(containerEl);
69 const serverData = opts?.serverData;
70 if (serverData) {
71 Object.assign(containerState.$serverData$, serverData);
72 }
73 const rCtx = createRenderContext(doc, containerState);
74 containerState.$hostsRendering$ = new Set();
75 containerState.$styleMoved$ = true;
76 await renderRoot(rCtx, containerEl, jsxOutput, doc, containerState, containerEl);
77
78 await postRendering(containerState, rCtx);
79
80 return {
81 cleanup() {
82 cleanupContainer(rCtx, containerEl);
83 },
84 };
85};
86
87const renderRoot = async (
88 rCtx: RenderContext,

Callers 6

store.unit.tsxFile · 0.90
render.unit.tsxFile · 0.90
render.unit.tsxFile · 0.50
component.unit.tsxFile · 0.50
sync-qrl.unit.tsxFile · 0.50
configureDevServerFunction · 0.50

Calls 10

jsxFunction · 0.90
getDocumentFunction · 0.90
qErrorFunction · 0.90
_getContainerStateFunction · 0.90
createRenderContextFunction · 0.90
postRenderingFunction · 0.90
getElementFunction · 0.85
injectQContainerFunction · 0.85
renderRootFunction · 0.70
hasAttributeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…