Frontmatter
| id | 8886 |
| title | fix: Ensure Collection.clear() clears allItems in filtered state |
| state | Closed |
| labels | bugaitesting |
| assignees | tobiu |
| createdAt | Jan 26, 2026, 8:26 PM |
| updatedAt | Jan 26, 2026, 8:30 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8886 |
| author | tobiu |
| commentsCount | 2 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 26, 2026, 8:30 PM |
fix: Ensure Collection.clear() clears allItems in filtered state
tobiu assigned to @tobiu on Jan 26, 2026, 8:28 PM

tobiu
Jan 26, 2026, 8:28 PM
Input from Gemini 3 Pro:
✦ I have implemented the fix and added the regression test.
Changes:
src/collection/Base.mjs: Updatedclear()to invokethis.allItems?.clear()before splicing. This ensures that the source collection (containing hidden/filtered items) is also wiped.test/playwright/unit/collection/MassiveData.spec.mjs: Added a comprehensive test suite that:
- Adds 10,000 items to a store.
- Applies a filter.
- Clears the store.
- Verifies
countis 0.- Adds another 10,000 items.
- Verifies that
allItemscorrectly reflects 10,000 items (not 20,000 or a corrupted state).- Checks for
undefineditems to ensure data integrity.- Verifies that adding a non-matching item to a filtered collection correctly updates
allItems.The test suite passes successfully.

tobiu
Jan 26, 2026, 8:29 PM
Input from Gemini 3 Pro:
✦ I have also updated
clearSilent()insrc/collection/Base.mjsto recursively clearallItemsif it exists. This ensures consistency for silent clear operations as well.
tobiu closed this issue on Jan 26, 2026, 8:30 PM
The
Collection.clear()method had a flaw when used on a filtered collection. It only cleared the visible items (this.items/this._items) but failed to clear the underlyingallItemscollection, which stores the full, unfiltered dataset.This behavior led to data corruption and retention issues, particularly in scenarios involving:
allItems. This could causeallItemsto grow indefinitely or contain mixed state from previous loads.Resolution: The
clear()method insrc/collection/Base.mjshas been updated to explicitly callthis.allItems?.clear()before clearing the local items.Regression Test: A new unit test file
test/playwright/unit/collection/MassiveData.spec.mjshas been added. It specifically targets:allItemsis correctly emptied.allItems(data loss check).