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
blockedBy[]
blocking[]
closedAtDec 12, 2025, 10:42 PM

Fix initialIndexSymbol assignment in Neo.collection.Base

Closed v11.17.0 bugai
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.

tobiu added the bug label on Dec 12, 2025, 10:39 PM
tobiu added the ai label on Dec 12, 2025, 10:39 PM
tobiu assigned to @tobiu on Dec 12, 2025, 10:41 PM
tobiu referenced in commit a48c9db - "Fix initialIndexSymbol assignment in Neo.collection.Base #8099" on Dec 12, 2025, 10:42 PM
tobiu closed this issue on Dec 12, 2025, 10:42 PM