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

Function patch

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

Source from the content-addressed store, hash-verified

1787}
1788
1789const patch = (inst: Instance, old: Rec, view: View.Node<any, any>): Rec => {
1790 const prev = old.v
1791 if (prev === view) {
1792 if (inst.tree.host.controlled !== undefined && view._tag === "Element") {
1793 restore(inst.tree.host, old)
1794 }
1795 return old
1796 }
1797 if (!pairs(prev, view)) return replace(inst, old, view)
1798 switch (view._tag) {
1799 case "Text":
1800 if ((prev as View.Text).text !== view.text) {
1801 inst.tree.host.setText(old.node, view.text)
1802 }
1803 old.v = view
1804 return old
1805 case "Element":
1806 patchElement(inst, old, prev as View.Element<any, any>, view)
1807 return old
1808 case "Child":
1809 return (view.bound as Placing | undefined)?.patch(inst, old, view) ??
1810 patchChild(inst, old, view)
1811 case "Outlet": {
1812 const placed = inst.placed!.get(view.name)
1813 if (placed?.rec !== old) return old
1814 if ((prev as View.Outlet).noText !== view.noText) {
1815 placed.content = refreshed
1816 }
1817 old.v = view
1818 refresh(inst, placed)
1819 return old
1820 }
1821 }
1822}
1823
1824/** @internal */
1825export const applyProps = (inst: Instance, props: unknown): boolean => {

Callers 6

renderFunction · 0.70
clearFunction · 0.70
settleFunction · 0.70
patchChildFunction · 0.70
patchElementFunction · 0.70
patchListFunction · 0.70

Calls 9

patchElementFunction · 0.85
patchChildFunction · 0.85
setTextMethod · 0.80
restoreFunction · 0.70
pairsFunction · 0.70
replaceFunction · 0.70
refreshFunction · 0.70
patchMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected