* For switching what owner sub-roots are attached to. * It'll remove the root from its current owner and attach it to the new owner.
(root: Solid.Root, newParent: Solid.Owner | null)
| 52 | * It'll remove the root from its current owner and attach it to the new owner. |
| 53 | */ |
| 54 | function changeRootAttachment(root: Solid.Root, newParent: Solid.Owner | null): void { |
| 55 | let topRoot: Solid.Root | undefined | null |
| 56 | |
| 57 | if (root.attachedTo) { |
| 58 | root.attachedTo.sdtSubRoots!.splice(root.attachedTo.sdtSubRoots!.indexOf(root), 1) |
| 59 | topRoot = getTopRoot(root.attachedTo) |
| 60 | if (topRoot) OnOwnerNeedsUpdate?.(root.attachedTo, getSdtId(topRoot, ObjectType.Owner)) |
| 61 | } |
| 62 | |
| 63 | if (newParent) { |
| 64 | root.attachedTo = newParent |
| 65 | if (newParent.sdtSubRoots) newParent.sdtSubRoots.push(root) |
| 66 | else newParent.sdtSubRoots = [root] |
| 67 | |
| 68 | if (topRoot === undefined) topRoot = getTopRoot(newParent) |
| 69 | if (topRoot) OnOwnerNeedsUpdate?.(newParent, getSdtId(topRoot, ObjectType.Owner)) |
| 70 | } else { |
| 71 | delete root.attachedTo |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Helps the debugger find and reattach an reactive owner created by `createRoot` to it's detached parent. |
no test coverage detected
searching dependent graphs…