MCPcopy Create free account
hub / github.com/QuarkGluonPlasma/react-course-code / commitWork

Function commitWork

mini-react/src/mini-react.js:259–280  ·  view source on GitHub ↗
(fiber)

Source from the content-addressed store, hash-verified

257 }
258
259 function commitWork(fiber) {
260 if (!fiber) {
261 return
262 }
263
264 let domParentFiber = fiber.return
265 while (!domParentFiber.dom) {
266 domParentFiber = domParentFiber.return
267 }
268 const domParent = domParentFiber.dom
269
270 if (fiber.effectTag === "PLACEMENT" && fiber.dom != null) {
271 domParent.appendChild(fiber.dom)
272 } else if (fiber.effectTag === "UPDATE" && fiber.dom != null) {
273 updateDom(fiber.dom, fiber.alternate.props, fiber.props)
274 } else if (fiber.effectTag === "DELETION") {
275 commitDeletion(fiber, domParent)
276 }
277
278 commitWork(fiber.child)
279 commitWork(fiber.sibling)
280 }
281
282 function commitDeletion(fiber, domParent) {
283 if (fiber.dom) {

Callers 1

commitRootFunction · 0.85

Calls 2

updateDomFunction · 0.85
commitDeletionFunction · 0.85

Tested by

no test coverage detected