LearnNewsExamplesServices
Frontmatter
id8477
titleRefactor Progress Component ID handling
stateClosed
labels
airefactoringcore
assigneestobiu
createdAtJan 9, 2026, 6:14 PM
updatedAtJan 9, 2026, 6:19 PM
githubUrlhttps://github.com/neomjs/neo/issues/8477
authortobiu
commentsCount1
parentIssue8469
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 9, 2026, 6:19 PM

Refactor Progress Component ID handling

Closed v11.19.1 airefactoringcore
tobiu
tobiu commented on Jan 9, 2026, 6:14 PM

Context: src/component/Progress.mjs uses afterSetId to update the for attribute of its label to match the component ID.

    afterSetId(value, oldValue) {
        super.afterSetId(value, oldValue);

        this.label.for = value;
        this.update()
    }

This is a standard DOM synchronization task. However, running it in afterSetId (before initConfig completes) triggers the prototype pollution risk (though mitigated by the construct fix, it's still cleaner to avoid).

Goal: Refactor afterSetId into ensureStableIds. Since ensureStableIds is called during VDOM updates (and initial creation), it's the perfect place to ensure structural attributes like for are synchronized with the ID.

Verification:

  • Create test/playwright/unit/component/Progress.spec.mjs.
  • Verify label.for matches component.id.
  • Verify changing id updates label.for.
tobiu added the ai label on Jan 9, 2026, 6:14 PM
tobiu added the refactoring label on Jan 9, 2026, 6:14 PM
tobiu added the core label on Jan 9, 2026, 6:14 PM
tobiu added parent issue #8469 on Jan 9, 2026, 6:14 PM
tobiu referenced in commit 1c2f6a7 - "refactor: replace afterSetId with ensureStableIds in Progress component (#8477)" on Jan 9, 2026, 6:17 PM
tobiu assigned to @tobiu on Jan 9, 2026, 6:18 PM
tobiu
tobiu Jan 9, 2026, 6:19 PM

Input from Gemini 3 Pro:

✦ I have refactored src/component/Progress.mjs to use ensureStableIds instead of afterSetId.

Changes:

  • Replaced afterSetId with ensureStableIds.
  • Moved the this.label.for = this.id logic into ensureStableIds.
  • This ensures the for attribute is always synchronized with the component ID during VDOM updates, without the need for manual update() calls or prototype pollution risks.

Verification:

  • Added test/playwright/unit/component/Progress.spec.mjs.
  • Verified that the label.for attribute correctly matches the component ID initially and after runtime changes.

Commit: 1c2f6a725 (#8477)

tobiu closed this issue on Jan 9, 2026, 6:19 PM