LearnNewsExamplesServices
Frontmatter
id9068
titleRefactor: Global Audit & Fix for ''keyProperty'' Access (Turbo Mode Compatibility)
stateClosed
labels
core
assigneestobiu
createdAtFeb 9, 2026, 3:44 AM
updatedAtFeb 10, 2026, 2:10 AM
githubUrlhttps://github.com/neomjs/neo/issues/9068
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 10, 2026, 2:10 AM

Refactor: Global Audit & Fix for 'keyProperty' Access (Turbo Mode Compatibility)

Closed v12.0.0 core
tobiu
tobiu commented on Feb 9, 2026, 3:44 AM

Context: The introduction of "Turbo Mode" (autoInitRecords: false) combined with Model Field Mapping has exposed a critical architectural vulnerability.

  • Turbo Mode: The Store holds Raw Objects (POJOs) to save memory.
  • Mapping: The Raw Object keys (e.g. 'l') differ from the Model's canonical field names (e.g. 'login').
  • KeyProperty: Stores are now configured with the canonical name (keyProperty: 'login') to align with Records.

The Problem: Many components (Grid, List, SelectionModel) and the Store itself access data using item[keyProperty].

  • On Raw Object: item['login'] is undefined. (It has 'l').
  • On Record: record['l'] is undefined. (It has 'login').

The Solution: We implemented Neo.data.Store#getKey(item) which handles this resolution transparently (checking direct access, then mapping, then getters).

Task: Perform a codebase-wide audit (src, apps, examples) to identify and refactor all locations where keyProperty or getKeyProperty() is used to access object properties directly. Replace them with store.getKey(item).

Critical Areas:

  • src/data/Store.mjs (Internal methods: find, insert, etc.)
  • src/list/Base.mjs (Item ID generation)
  • src/grid/ (Any remaining spots)
  • examples/ (To ensure demos don't break)

Goal: Ensure the framework is robust against Mixed Mode (Raw/Record) data storage.

tobiu assigned to @tobiu on Feb 9, 2026, 3:44 AM
tobiu added the core label on Feb 9, 2026, 3:44 AM
tobiu referenced in commit 9556e57 - "refactor: Global Audit & Fix for 'keyProperty' Access (Turbo Mode Compatibility) (#9068)" on Feb 9, 2026, 11:01 AM
tobiu
tobiu Feb 9, 2026, 11:02 AM

Input from Gemini 3 Pro:

Task Completed: Global Audit & Fix for 'keyProperty' Access (Turbo Mode Compatibility)

Objective: Ensure framework robustness against Mixed Mode (Raw/Record) data storage, specifically addressing the "Turbo Mode" (autoInitRecords: false) scenario where raw object keys (e.g., 'l') differ from Model field names (e.g., 'login').

Key Implementations:

  1. Polymorphic Key Resolution (getKey()):

    • Refactored src/data/Store.mjs and src/collection/Base.mjs to replace direct keyProperty access with me.getKey(item).
    • This method intelligently resolves keys from either Records (via getters) or Raw Objects (via direct access or mapping lookup).
    • Critical Internal Methods Updated: add, find, findBy, insert, initRecord, afterSetItems, and filter.
  2. Robust ID Parsing (getKeyType()):

    • Updated src/list/Base.mjs to use store.getKeyType()?.includes('int') for strictly determining when to parse DOM IDs back into integers.
    • This replaces brittle manual checks and prevents issues with string-based IDs in non-Model Stores.
    • Propagated to: src/component/Gallery.mjs, src/component/Helix.mjs, src/list/Component.mjs.

Scope of Refactoring:

  • Files Changed: 18 files across src, apps, and examples.
  • Components Updated:
    • Neo.list.Base, Neo.list.Component
    • Neo.menu.List
    • Neo.component.Gallery, Neo.component.Helix
    • Neo.tree.Accordion
    • Calendar views (ColorsList, CalendarsList)
  • Apps/Examples Verified: apps/realworld2, apps/covid, apps/sharedcovid, examples/component/corona*.

Outcome: The framework can now safely handle mixed data types in Stores, preserving the performance benefits of Turbo Mode while maintaining correct item identification and selection logic across all major data-bound components.

tobiu closed this issue on Feb 10, 2026, 2:10 AM