MCPcopy Create free account
hub / github.com/MMmaXingXing/mini-vue / mountElement

Function mountElement

copy_code/src/runtime-core/renderer.ts:23–42  ·  view source on GitHub ↗
(vnode, container)

Source from the content-addressed store, hash-verified

21};
22
23export const mountElement = (vnode, container) => {
24 const el = document.createElement(vnode.type);
25
26 // 子元素处理
27 const { children } = vnode;
28 if (typeof children === "string") {
29 el.textContent = children;
30 } else if (Array.isArray(children)) {
31 mountChildren(vnode, el);
32 }
33
34 // 参数处理
35 const { props } = vnode;
36 for (const key in props) {
37 const val = props[key];
38 el.setAttribute(key, val);
39 }
40
41 container.append(el);
42};
43
44const mountChildren = (vnode, container) => {
45 vnode.children.forEach((v) => {

Callers 1

processElementFunction · 0.70

Calls 2

createElementMethod · 0.80
mountChildrenFunction · 0.70

Tested by

no test coverage detected