Skip to content

refactor(components): standardize component teardown method to onBeforeRemove#8885

Merged
willeastcott merged 1 commit into
mainfrom
refactor/component-onbeforeremove
Jun 12, 2026
Merged

refactor(components): standardize component teardown method to onBeforeRemove#8885
willeastcott merged 1 commit into
mainfrom
refactor/component-onbeforeremove

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

Summary

#8882 standardized the system-side beforeremove handler name to onBeforeRemove. This PR completes the standardization on the component side: the teardown method that handler invokes was still named three different ways across the engine.

  • onRemove()onBeforeRemove() — button, camera, element, gsplat, layout-group, light, model, render, screen, scroll-view, scrollbar, sound (12 components + their system call sites)
  • _onBeforeRemove()onBeforeRemove() — zone, script, joint
  • onDestroy()onBeforeRemove() — sprite

Purely mechanical rename: 31 files, 1 line each (definition or call site). No behavioral change.

Intentionally unchanged: the collision system's system-level onRemove(entity) (collision/system.js:742), which is bound to the distinct remove event rather than beforeremove, and the unrelated onRemoveChild handlers in model/render/gsplat.

Note: JointComponent.onBeforeRemove (renamed from _onBeforeRemove) still has no caller — JointComponentSystem never binds the beforeremove event, so joint constraints are not torn down on removeComponent. That's a pre-existing bug worth a separate fix rather than folding into this mechanical rename.

These methods are engine-internal (invoked only by the component systems), but external code calling them by their old names would need updating.

Testing

  • npm test — 1817 passing
  • ESLint clean on all touched files
  • git grep confirms no remaining references to the old method names

🤖 Generated with Claude Code

…reRemove

PR #8882 standardized the system-side 'beforeremove' handler name to
onBeforeRemove. This completes the standardization on the component
side, where the teardown method invoked by that handler was still
named inconsistently:

- onRemove() -> onBeforeRemove() in button, camera, element, gsplat,
  layout-group, light, model, render, screen, scroll-view, scrollbar
  and sound
- _onBeforeRemove() -> onBeforeRemove() in zone, script and joint
- onDestroy() -> onBeforeRemove() in sprite

The collision system's own system-level onRemove (bound to the
distinct 'remove' event) is intentionally unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the component-side portion of the teardown naming standardization by renaming component teardown methods to onBeforeRemove() and updating the corresponding component-system call sites. It aligns component teardown naming with the already-standardized system-side beforeremove handler naming (from #8882), without changing teardown behavior.

Changes:

  • Renamed component teardown methods (onRemove(), _onBeforeRemove(), onDestroy()) to onBeforeRemove() across affected components.
  • Updated each corresponding component system onBeforeRemove(entity, component) handler to call component.onBeforeRemove().
  • Kept unrelated onRemove handlers (e.g., collision system’s remove event handler) and other unrelated “remove” methods (e.g., onRemoveChild) unchanged.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/framework/components/zone/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/zone/component.js Renames _onBeforeRemove() to onBeforeRemove().
src/framework/components/sprite/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/sprite/component.js Renames onDestroy() to onBeforeRemove().
src/framework/components/sound/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/sound/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/scrollbar/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/scrollbar/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/scroll-view/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/scroll-view/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/script/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/script/component.js Renames _onBeforeRemove() to onBeforeRemove().
src/framework/components/screen/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/screen/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/render/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/render/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/model/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/model/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/light/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/light/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/layout-group/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/layout-group/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/joint/component.js Renames _onBeforeRemove() to onBeforeRemove().
src/framework/components/gsplat/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/gsplat/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/element/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/element/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/camera/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/camera/component.js Renames onRemove() to onBeforeRemove().
src/framework/components/button/system.js Updates system teardown call to component.onBeforeRemove().
src/framework/components/button/component.js Renames onRemove() to onBeforeRemove().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@willeastcott willeastcott merged commit be94fc3 into main Jun 12, 2026
10 checks passed
@willeastcott willeastcott deleted the refactor/component-onbeforeremove branch June 12, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants