Skip to content

Conversation

@MatAtBread
Copy link
Owner

No description provided.

ai-ui.ts
* Add replaced nodes to removedNodes
* Correct updating of appended to deal with re-ordered (out of order) nodes

iterators.ts
* Release ref to `prev` in filterMap on termination
* Release ref to `current` in multi on termination

when.ts
* Move elementIsInDOM() and allSelectorsPresent() into containerAndSelectorsMounted() and use a closure to access the containing element
* Reject in elementIsInDOM() if elt is *removed*
Next attempt will change the return type of nodes() to a sync iterator to prevent the need to update the appended array. Instead the result will flatten the `replacementNodes` see branch v0.15.6-sync-nodes
The removes the need to reference the returned value in a closure, in case is it updated. Instead, it is lazily walked on demand, including any updates. This appears to work fine (needs full tests).

On examination, the remaining leak is when a node is removed and there is no subsequent iteration to unwind the references. This can happen, for example, when a node depends on a child it is expecting to receieve events, but the child is removed and so the container (with an implicit reference to teh child) never receives another input event from the removed child, leaving it in the async iteration state forever, having never called ai.return() (or throw)
...by checking when a DOM node is removed if any associated async iterator should be terminated. This is acheieved by weakly associating the termination function with the node, which is invoked by the mutationTracker.
Update the mutationTracker to terminate (and therefore de-reference and unwind) source async iterators on node removal.
* Fold ai-ui-style tags into one per document
* Re-implement legacy onRemovedFromDOM as tracked removal handler
* Log exceptions in removal handlers
* Ensure correct `this` in isAncestral (debug only)
@MatAtBread MatAtBread merged commit 0cf4fa9 into main Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants