* 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 )
| 2225 | * @internal |
| 2226 | */ |
| 2227 | function 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. |
no test coverage detected