{"record":{"id":"e901508e04bff81b","repo":"leptos-rs/leptos","slug":"hot-reloading-child-at","errorCode":null,"errorMessage":"[HOT RELOADING] Child at ","messagePattern":"\\[HOT RELOADING\\] Child at ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"leptos_hot_reload/src/patch.js","lineNumber":456,"sourceCode":"\n  function childAtPath(element, path) {\n    if (path.length == 0) {\n      return element;\n    } else if (element.children) {\n      const next = element.children[path[0]],\n        rest = path.slice(1);\n      return childAtPath(next, rest);\n    } else if (path == [0]) {\n      return element;\n    } else if (element.start && element.end) {\n      const actualChildren = childrenFromRange(\n        element.node || element.start.parentElement,\n        element.start,\n        element.end,\n      );\n      return childAtPath({ children: actualChildren }, path);\n    } else {\n      console.warn(\"[HOT RELOADING] Child at \", path, \"not found in \", element);\n      return element;\n    }\n  }\n\n  function childrenFromRange(parent, start, end) {\n    const range = new Range();\n    range.setStartAfter(start);\n    range.setEndBefore(end);\n    return buildActualChildren(parent, range);\n  }\n\n  function fromHTML(html) {\n    const template = document.createElement(\"template\");\n    template.innerHTML = html;\n    return template.content.cloneNode(true);\n  }\n}\n","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/leptos_hot_reload/src/patch.js#L438-L474","documentation":"childAtPath could not descend the given path: the current element has no `children` array and no `start`/`end` marker range to lazily rebuild children from. It logs a warning and returns the current element, so the patch proceeds against the wrong node (a shallower subtree) rather than failing loudly — the patch may then be applied to an incorrect DOM location.","triggerScenarios":"A patch path is deeper than the actual child tree — e.g. path indexes past the rebuilt children, or the intermediate child resolved to a 'text'/'unit' node with no children; also when element.children exists but path[i] is out of bounds (element.children[path[0]] is undefined and the next recursion hits this branch).","commonSituations":"Version mismatch between the server's path computation and the client's child model; DOM edited between saves so indexes shifted; editing inside views leptos does not mark (dynamic children without markers).","solutions":["Hard-reload the page and re-save so paths are computed against a fresh DOM.","Verify the path indexes in the logged warning against the actual view structure; an off-by-one usually means a sibling was added/removed.","Ensure leptos and leptos_hot_reload crate versions are in sync.","Apply structural edits one at a time rather than batching several subtree changes per save."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before applying a patch path, confirm it resolves:\nconst child = childAtPath(root, patch.path);\nif (child === root && patch.path.length > 0) {\n  console.warn('path unresolved, forcing reload');\n  location.reload();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reload instead of stacking edits when path warnings appear.","Keep server crate and patch.js versions aligned.","Compare the logged path against your view structure to catch off-by-one index shifts early."],"tags":["hot-reload","dom-patching","path-resolution"],"backgroundTag":"hot-reload-path-not-found","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}