Skip to content

fix(target): detect target changes and rebind handlers#19

Merged
STRML merged 2 commits intomasterfrom
fix/target-change-detection
Dec 31, 2025
Merged

fix(target): detect target changes and rebind handlers#19
STRML merged 2 commits intomasterfrom
fix/target-change-detection

Conversation

@STRML
Copy link
Owner

@STRML STRML commented Dec 31, 2025

Summary

  • Fix bug where changing the target prop without changing handler keys would not trigger a rebind
  • Listeners now properly move from old target to new target when target changes
  • Works with both direct target references and target functions

Changes

  • componentDidUpdate now compares resolved targets using getTarget(prevProps) !== getTarget(this.props)
  • Added 2 new tests for target change detection (direct and function targets)
  • Added GitHub Actions CI workflow for lint, test, and build across Node 18, 20, 22

Test plan

  • Existing tests pass (20 total)
  • New tests verify target-only changes trigger rebind
  • Lint passes
  • Build passes

Previously, changing the `target` prop without changing handler keys
would not trigger a rebind - the listeners would remain on the old
target. Now the component compares resolved targets and rebinds when
they differ.

Also adds GitHub Actions CI workflow for lint, test, and build
across Node 18, 20, and 22.
@STRML STRML merged commit a47ad92 into master Dec 31, 2025
3 checks passed
@STRML STRML deleted the fix/target-change-detection branch December 31, 2025 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant