refactor(components): standardize component teardown method to onBeforeRemove#8885
Merged
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
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()) toonBeforeRemove()across affected components. - Updated each corresponding component system
onBeforeRemove(entity, component)handler to callcomponent.onBeforeRemove(). - Kept unrelated
onRemovehandlers (e.g., collision system’sremoveevent 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#8882 standardized the system-side
beforeremovehandler name toonBeforeRemove. 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, jointonDestroy()→onBeforeRemove()— spritePurely 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 distinctremoveevent rather thanbeforeremove, and the unrelatedonRemoveChildhandlers in model/render/gsplat.Note:
JointComponent.onBeforeRemove(renamed from_onBeforeRemove) still has no caller —JointComponentSystemnever binds thebeforeremoveevent, so joint constraints are not torn down onremoveComponent. 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 passinggit grepconfirms no remaining references to the old method names🤖 Generated with Claude Code