MCPcopy Create free account
hub / github.com/Effect-TS/effect / patchChild

Function patchChild

packages/effect/src/ui/internal/kernel.ts:1867–1901  ·  view source on GitHub ↗
(
  inst: Instance,
  old: Rec,
  view: View.Child<any, any>
)

Source from the content-addressed store, hash-verified

1865
1866/** @internal */
1867export const patchChild = (
1868 inst: Instance,
1869 old: Rec,
1870 view: View.Child<any, any>
1871): Rec => {
1872 const child = old.inst
1873 const shown = old.kids
1874 if (shown === undefined && inst.tree.holds?.(child, inst, view) === true) {
1875 return old
1876 }
1877 // Hydration replays a held view outside any render, and slot content can patch without one.
1878 inst.tree.flushes?.writing()
1879 old.v = view
1880 if (shown !== undefined) {
1881 // The host settles a held child with the latest view.
1882 if (shown[0]!.v === heldText) return old
1883 shown[0] = child === inst
1884 ? inFallback(inst, () => patch(inst, shown[0]!, fallbackOf(inst, view, causeOf(inst, view))))
1885 : patch(inst, shown[0]!, fallbackOf(inst, view, child.failure))
1886 return old
1887 }
1888 const changed = applyProps(child, view.props)
1889 if (child.closed) return old
1890 if (changed || view.view !== undefined) {
1891 if (child === receiving) markDirty(child)
1892 else render(child)
1893 }
1894 const placed = child.placed
1895 if (placed !== undefined && !child.closed) {
1896 for (const entry of placed.values()) {
1897 refresh(child, entry)
1898 }
1899 }
1900 return old
1901}
1902
1903/** @internal */
1904export const replace = (

Callers 1

patchFunction · 0.85

Calls 9

inFallbackFunction · 0.85
fallbackOfFunction · 0.85
applyPropsFunction · 0.85
writingMethod · 0.80
patchFunction · 0.70
causeOfFunction · 0.70
markDirtyFunction · 0.70
renderFunction · 0.70
refreshFunction · 0.70

Tested by

no test coverage detected