hotwired/stimulus

Callback Ordering Inconsistency in Documentation

zacheryph opened this issue · 1 comments

The ordering of callbacks is inconsistent in the documentation. It'd be nice if they were consistent. One place notes [name]TargetConnected callbacks get called before connect, and the other says it gets called after.

"Lifecycle" wise and setup, it'd make sense that the target callbacks happen after connect() and before disconnect(). Note, the disconnect callbacks are consistent on both pages.

Reference > Lifecycle Callbacks

This page states the following

The [name]TargetConnected() lifecycle callbacks will fire before the controller’s connect() callback.

Reference > Targets

This page states the opposite

Stimulus invokes each element callback any time its target elements are added or removed after connect() and before disconnect() lifecycle hooks.

This is actually more wrong than correct. From my testing;

  • [name]TargetConnected() gets called before connect()
    this means Lifecycle Callbacks is correct
  • [name]TargetDisconnected() gets called after disconnect()
    this means both pages are wrong.