MCPcopy Create free account
hub / github.com/formkit/formkit / destroy

Function destroy

packages/core/src/node.ts:2227–2247  ·  view source on GitHub ↗

* This node is being removed and needs to be cleaned up. * * @param node - A FormKitNode | FormKitNode * @param context - A FormKitContext | FormKitContext * * @internal

(
  node: FormKitNode,
  context: FormKitContext,
  emitDestroying = true
)

Source from the content-addressed store, hash-verified

2225 * @internal
2226 */
2227function destroy(
2228 node: FormKitNode,
2229 context: FormKitContext,
2230 emitDestroying = true
2231) {
2232 if (emitDestroying) node.emit('destroying', node)
2233 // flush all messages out
2234 node.store.filter(() => false)
2235 if (node.parent) {
2236 node.parent.remove(node)
2237 }
2238 deregister(node)
2239 node.emit('destroyed', node)
2240 context._e.flush()
2241 context._value = context.value = undefined
2242 for (const property in context.context) {
2243 delete context.context[property]
2244 }
2245 context.plugins.clear()
2246 context.context = null! // eslint-disable-line @typescript-eslint/no-non-null-assertion
2247}
2248
2249/**
2250 * Defines the current input type concretely.

Callers 1

syncListNodesFunction · 0.85

Calls 1

deregisterFunction · 0.90

Tested by

no test coverage detected