refactor(components): standardize beforeremove handler naming#8882
Merged
Conversation
The system method bound to the beforeremove event was named five different ways across component systems (onBeforeRemove, onRemove, _onRemoveComponent, onRemoveComponent, _onBeforeRemove). Rename all of them to onBeforeRemove, matching the majority convention already used by camera, sound, animation, anim, rigid-body, collision, sprite and particle-system. Component-side methods (component.onRemove, component._onBeforeRemove) are untouched, as is collision''s separate onRemove handler which is bound to the distinct remove event. Also removes a redundant this.app assignment from JointComponentSystem (the base ComponentSystem constructor already sets it). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes the naming of component system handlers bound to the beforeremove event by renaming them to onBeforeRemove across the remaining inconsistent systems, aligning with the majority convention in src/framework/components. It also removes a redundant this.app = app assignment from JointComponentSystem since the base ComponentSystem constructor already sets it.
Changes:
- Renamed various
beforeremovesystem handlers (_onRemoveComponent,onRemove,onRemoveComponent,_onBeforeRemove) toonBeforeRemove(bindings + method definitions). - Kept handler behavior unchanged (method bodies remain the same; only system method names changed).
- Removed redundant
this.app = appassignment inJointComponentSystem.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/framework/components/button/system.js | Rename beforeremove handler to onBeforeRemove. |
| src/framework/components/element/system.js | Rename beforeremove handler to onBeforeRemove. |
| src/framework/components/gsplat/system.js | Rename beforeremove handler from onRemove to onBeforeRemove. |
| src/framework/components/joint/system.js | Remove redundant this.app = app assignment (already set by base class). |
| src/framework/components/layout-group/system.js | Rename beforeremove handler to onBeforeRemove. |
| src/framework/components/light/system.js | Rename beforeremove handler to onBeforeRemove. |
| src/framework/components/model/system.js | Rename beforeremove handler from onRemove to onBeforeRemove. |
| src/framework/components/render/system.js | Rename beforeremove handler from onRemove to onBeforeRemove. |
| src/framework/components/screen/system.js | Rename beforeremove handler from onRemoveComponent to onBeforeRemove. |
| src/framework/components/script/system.js | Rename beforeremove handler to onBeforeRemove. |
| src/framework/components/scroll-view/system.js | Rename beforeremove handler to onBeforeRemove. |
| src/framework/components/scrollbar/system.js | Rename beforeremove handler to onBeforeRemove. |
| src/framework/components/zone/system.js | Rename beforeremove handler from _onBeforeRemove to onBeforeRemove. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jun 12, 2026
willeastcott
added a commit
that referenced
this pull request
Jun 12, 2026
…reRemove (#8885) 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>
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
Fifth and final PR in the component-consistency series (follows #8878, #8879, #8880, #8881).
The system method bound to the
beforeremoveevent was named five different ways across the 20 component systems that bind it:onBeforeRemove(kept)_onRemoveComponentonRemoveonRemoveComponent_onBeforeRemoveAll are now
onBeforeRemove, matching the majority convention. Rename-only — every binding and method body is otherwise unchanged.Deliberately untouched:
component.onRemove(),component._onBeforeRemove()) — only the system methods are renamed.onRemove— it is bound to the distinctremoveevent, notbeforeremove, so its name already follows the convention._onBeforeRemoveentry inscript/constants.js— that is the reserved component-side script instance method, not the system handler.Also removes a redundant
this.app = appassignment fromJointComponentSystem(the baseComponentSystemconstructor already sets it).Verified no references to the old names remain anywhere in
src/,test/, orexamples/(these were undocumented internals with no external call sites).Testing
npm testsuite passes (1817 passing), no test edits needed🤖 Generated with Claude Code