Frontmatter
| id | 8888 |
| title | core: Collection.destroy() should cleanup allItems, sorters and filters |
| state | Closed |
| labels | airefactoringcore |
| assignees | tobiu |
| createdAt | Jan 26, 2026, 8:59 PM |
| updatedAt | Jan 26, 2026, 9:02 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8888 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 26, 2026, 9:02 PM |
core: Collection.destroy() should cleanup allItems, sorters and filters
tobiu assigned to @tobiu on Jan 26, 2026, 9:02 PM

tobiu
Jan 26, 2026, 9:02 PM
Input from Gemini 3 Pro:
✦ I have implemented the requested cleanup logic in
Collection.destroy().Changes in
src/collection/Base.mjs:
allItemsCleanup: Addedme.allItems?.destroy().filtersCleanup: Addedme.filters?.forEach(item => item?.destroy()).sortersCleanup: Addedme.sorters?.forEach(item => item?.destroy()).I used the optional chaining operator
item?.destroy()inside the loops as requested for maximum safety.Verification: Running
npm run test-unit -- collection/Baseconfirms that the changes do not introduce any regressions.
tobiu closed this issue on Jan 26, 2026, 9:02 PM
Title: core: Collection.destroy() should cleanup allItems, sorters and filters
Labels: core, refactoring, ai
Body: The current implementation of
Collection.destroy()only clears_itemsandmap. It should also:allItemsif it exists.sortersandfiltersinstances if they exist (they are typically instances ofNeo.collection.SorterandNeo.collection.Filter).Proposed change:
/** * Clears the map & items array before the super call */ destroy() { let me = this; me.allItems?.destroy(); me.filters?.forEach(item => { if (item.destroy) { item.destroy() } }); me.sorters?.forEach(item => { if (item.destroy) { item.destroy() } }); me._items.splice(0, me._items.length); me.map.clear(); super.destroy() }