LearnNewsExamplesServices
Frontmatter
titlefix/functional.component.Base: enhance destroy() signature
authorad1tyayadav
stateMerged
createdAtOct 26, 2025, 3:04 PM
updatedAtOct 27, 2025, 11:45 AM
closedAtOct 27, 2025, 11:45 AM
mergedAtOct 27, 2025, 11:45 AM
branchesdevfix-functional-destroy
urlhttps://github.com/neomjs/neo/pull/7667
Merged
ad1tyayadav
ad1tyayadav commented on Oct 26, 2025, 3:04 PM

Closes #7062

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

The PR fulfills this requirement:

  • It's submitted to the dev branch, not the main branch

Other information:

Summary

Enhanced the destroy() method signature in functional.component.Base to match the pattern used in component.Base and container.Base.

Changes

  • Added updateParentVdom and silent parameters to the destroy() method
  • Pass silent=true when destroying child components to prevent unnecessary vdom updates
  • Pass parameters to super.destroy() for consistency with component hierarchy

Why This Change?

  • Performance: Prevents each child component from triggering individual vdom worker calls during batch destruction
  • Consistency: Matches the established pattern in component.Base (L1144) and container.Base (L476)
  • Optimization: Avoids unnecessary calls to the vdom worker when destroying components with multiple children

Testing

The change follows the existing pattern from:

  • src/component/Base.mjs#L1144
  • src/container/Base.mjs#L476
  • src/component/Abstract.mjs#L284

No breaking changes - the method remains backwards compatible with default parameter values.

ad1tyayadav
ad1tyayadav commented on Oct 26, 2025, 3:16 PM

Hey @tobiu can you please review this pr?


tobiu
tobiu commented on Oct 27, 2025, 11:44 AM

Input from Gemini:

✦ This is an excellent and crucial optimization. My initial review was too superficial. After reviewing the 'Functional Components' epic and the base classes, I have a much deeper appreciation for this change.

When a functional.component.Base hosts classic components, it must act as a responsible owner for their lifecycle. This PR correctly applies the established, performant destruction pattern from container.Base to the functional component's classic children. By calling destroy(false, true), it prevents a potential storm of VDOM updates and ensures that the two component paradigms can interoperate efficiently.

This is a great catch and a solid implementation. LGTM!