LearnNewsExamplesServices
Frontmatter
id8478
titleRefactor afterSetId in Form Fields to ensureStableIds
stateClosed
labels
airefactoringcore
assigneestobiu
createdAtJan 9, 2026, 6:20 PM
updatedAtJan 9, 2026, 6:25 PM
githubUrlhttps://github.com/neomjs/neo/issues/8478
authortobiu
commentsCount1
parentIssue8469
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtJan 9, 2026, 6:25 PM

Refactor afterSetId in Form Fields to ensureStableIds

tobiu
tobiu commented on Jan 9, 2026, 6:20 PM

Context: src/form/field/CheckBox.mjs, src/form/field/FileUpload.mjs, and src/form/field/Text.mjs all implement afterSetId to manually update ID attributes of their internal VDOM nodes (inputs, labels, icons, etc.). This pattern is consistent across these form fields.

Goal: Refactor afterSetId into ensureStableIds for all three files. This will:

  1. Ensure ID synchronization happens during the VDOM update preparation phase.
  2. Remove potential prototype pollution risks (mitigated by construct fix but still cleaner).
  3. Standardize the codebase on ensureStableIds.

Files:

  • src/form/field/CheckBox.mjs: label, input, icon, valueLabel IDs.
  • src/form/field/FileUpload.mjs: input ID.
  • src/form/field/Text.mjs: input, label IDs.

Verification:

  • Create test/playwright/unit/form/field/IdSync.spec.mjs.
  • Test each field type:
    • Create instance.
    • Check internal node IDs match the component ID structure.
    • Change ID.
    • Verify internal node IDs update.
tobiu
tobiu Jan 9, 2026, 6:24 PM

Input from Gemini 3 Pro:

✦ I have refactored afterSetId to ensureStableIds in:

  • src/form/field/CheckBox.mjs
  • src/form/field/FileUpload.mjs
  • src/form/field/Text.mjs

Changes:

  • Replaced afterSetId with ensureStableIds.
  • ID synchronization logic for internal elements (inputs, labels, icons) is now handled during VDOM preparation.
  • This eliminates the need for manual update() calls in ID setters and further reduces prototype pollution risks.

Verification:

  • Added test/playwright/unit/form/field/IdSync.spec.mjs.
  • Verified that all internal node IDs (e.g. __input, __label) and attributes (for) are correctly synchronized with the component ID for all three field types.

Commit: 91085ea4f (#8478)