MCPcopy Create free account
hub / github.com/UI5/webcomponents / jsxRenderer

Function jsxRenderer

packages/base/src/renderer/JsxRenderer.ts:8–29  ·  view source on GitHub ↗
(instance: UI5Element, container: HTMLElement | DocumentFragment)

Source from the content-addressed store, hash-verified

6const instanceToContextMap = new WeakMap<UI5Element, ReturnType<typeof createContext<UI5Element>>>();
7
8const jsxRenderer: Renderer = (instance: UI5Element, container: HTMLElement | DocumentFragment) => {
9 let ctx = instanceToContextMap.get(instance);
10 if (!ctx) {
11 // create a context holding the element that is being rendered
12 // this contect will be used when adding event listeners - they all will be bound to this element
13 ctx = createContext(instance);
14 instanceToContextMap.set(instance, ctx);
15 }
16
17 const templateResult = instance.render();
18 const vnode = jsx(ctx.Provider, { value: instance, children: templateResult });
19
20 if (instance.__shouldHydrate) {
21 // Remove all server-generated style elements for component styles
22 // to avoid conflicts or duplication with styles added through adopted style sheets.
23 instance.shadowRoot?.querySelectorAll("style").forEach(style => style.remove());
24 hydrate(vnode, container);
25 instance.__shouldHydrate = false;
26 } else {
27 render(vnode, container);
28 }
29};
30
31export default jsxRenderer;

Callers

nothing calls this directly

Calls 5

jsxFunction · 0.90
renderFunction · 0.90
getMethod · 0.80
removeMethod · 0.80
renderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…