LearnNewsExamplesServices
Frontmatter
id8099
titleFix initialIndexSymbol assignment in Neo.collection.Base
stateClosed
labels
bugai
assigneestobiu
createdAtDec 12, 2025, 10:39 PM
updatedAtDec 12, 2025, 10:42 PM
githubUrlhttps://github.com/neomjs/neo/issues/8099
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtDec 12, 2025, 10:42 PM

Fix initialIndexSymbol assignment in Neo.collection.Base

tobiu
tobiu commented on Dec 12, 2025, 10:39 PM

Problem

The splice method in Neo.collection.Base was unconditionally assigning the initialIndexSymbol to all added items if they didn't already have it.

// Previous Logic
if (!Object.hasOwn(item, initialIndexSymbol)) {
    item[initialIndexSymbol] = me.initialIndexCounter++
}

This caused plain objects in generic collections to be polluted with this symbol, leading to unit test failures in Neo.collection.Base.

Solution

Invert the logic to only assign the index counter if the item already possesses the symbol key (which Neo.data.Record instances do, initialized to null).

// New Logic
if (Object.hasOwn(item, initialIndexSymbol)) {
    item[initialIndexSymbol] = me.initialIndexCounter++
}

This ensures the feature is "opt-in" and works correctly for Neo.data.Store (where records have the symbol) while ignoring plain objects in standard collections.