#809·stimulus

Custom `targetAttributeForScope` breaks target lifecycle callbacks

Author: koenkivitsCreated Jan 21, 2025Updated Jan 21, 2025

When using a custom targetAttributeForScope callback, target (dis)connected callbacks no longer work. This seems to be because TargetObserver hardcodes the default attribute format:

https://github.com/hotwired/stimulus/blob/101a060f961e9240b55b29e25fdfe82c79b9c5b0/src/core/target_observer.ts#L75-L77

All target properties on the controller ([name]Target, has[Name]Target, etc) do work as expected.