Frontmatter
| id | 8474 |
| title | Enforce Eager VDOM Cloning in Component Constructor |
| state | Closed |
| labels | bugairefactoringcore |
| assignees | tobiu |
| createdAt | Jan 9, 2026, 5:42 PM |
| updatedAt | Jan 9, 2026, 5:45 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8474 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 8469 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 9, 2026, 5:45 PM |
Enforce Eager VDOM Cloning in Component Constructor
tobiu added parent issue #8469 on Jan 9, 2026, 5:43 PM
tobiu assigned to @tobiu on Jan 9, 2026, 5:45 PM

tobiu
Jan 9, 2026, 5:45 PM
Input from Gemini 3 Pro:
✦ I have implemented the eager VDOM cloning mechanism in
src/component/Base.mjs.Changes:
- Overrode the
construct(config)method inNeo.component.Base.- Added a check
!Object.hasOwn(this, '_vdom') && this._vdom.- If true, it performs
this._vdom = Neo.clone(this._vdom, true)before callingsuper.construct(config).Why this is critical:
super.construct(incore.Base) setsthis.id, which triggersafterSetId.- Some legacy code or anti-patterns might access
this._vdom(direct private access) insideafterSetIdor other early setters.- By ensuring
_vdomis an instance property before the parent constructor runs, we effectively "firewall" the prototype against any mutation during the entire construction sequence.Verification:
- Added
test/playwright/unit/component/Base_PrototypePollution_Direct.spec.mjs.- This test explicitly bypasses the getter and accesses
this._vdomdirectly inafterSetId.- The test passed, confirming the prototype remains clean.
Commit: 12958cae8 (#8474)
tobiu closed this issue on Jan 9, 2026, 5:45 PM
tobiu cross-referenced by #8469 on Jan 9, 2026, 6:26 PM
Context: The previous fix (#8472) added lazy cloning to the
vdomgetter. However, if a subclass accessesthis._vdomdirectly (bypassing the getter) during the construction phase (e.g. inafterSetId), prototype pollution still occurs.Goal: Implement
construct()inNeo.component.Baseto perform eager cloning of the VDOM if it hasn't been cloned yet. This ensures thatthis._vdomis an instance property beforesuper.construct()runs (which triggersafterSetId).Verification: Use
test/playwright/unit/component/Base_PrototypePollution_Direct.spec.mjsto verify that direct access is also safe.