handles reconcilation maps children via key or index (exclusively)
(elems []vdom.VDomElem, curChildren []*ComponentImpl, containingComp string, opts *RenderOpts)
| 149 | // handles reconcilation |
| 150 | // maps children via key or index (exclusively) |
| 151 | func (r *RootElem) renderChildren(elems []vdom.VDomElem, curChildren []*ComponentImpl, containingComp string, opts *RenderOpts) []*ComponentImpl { |
| 152 | newChildren := make([]*ComponentImpl, len(elems)) |
| 153 | curCM := make(map[ChildKey]*ComponentImpl) |
| 154 | usedMap := make(map[*ComponentImpl]bool) |
| 155 | for idx, child := range curChildren { |
| 156 | if child.Key != "" { |
| 157 | curCM[ChildKey{Tag: child.Tag, Idx: 0, Key: child.Key}] = child |
| 158 | } else { |
| 159 | curCM[ChildKey{Tag: child.Tag, Idx: idx, Key: ""}] = child |
| 160 | } |
| 161 | } |
| 162 | for idx, elem := range elems { |
| 163 | elemKey := getElemKey(&elem) |
| 164 | var curChild *ComponentImpl |
| 165 | if elemKey != "" { |
| 166 | curChild = curCM[ChildKey{Tag: elem.Tag, Idx: 0, Key: elemKey}] |
| 167 | } else { |
| 168 | curChild = curCM[ChildKey{Tag: elem.Tag, Idx: idx, Key: ""}] |
| 169 | } |
| 170 | usedMap[curChild] = true |
| 171 | newChildren[idx] = curChild |
| 172 | r.render(&elem, &newChildren[idx], containingComp, opts) |
| 173 | } |
| 174 | for _, child := range curChildren { |
| 175 | if !usedMap[child] { |
| 176 | r.unmount(&child) |
| 177 | } |
| 178 | } |
| 179 | return newChildren |
| 180 | } |
| 181 | |
| 182 | // safely calls the component function with panic recovery |
| 183 | func callCFuncWithErrorGuard(cfunc any, props map[string]any, componentName string) (result any) { |
no test coverage detected