Skip to content

Commit

Permalink
Fix Inconsistency with Callback Ordering (hotwired#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
zacheryph committed Mar 19, 2024
1 parent 0cb23ed commit f3dff4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/reference/lifecycle_callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ A connected target will later become _disconnected_ when either of the preceding
* the element's `data-{identifier}-target` attribute is removed or modified
* the document installs a new `<body>` element, such as during a Turbo page change

When a target becomes disconnected, Stimulus calls its controller's `[name]TargetDisconnected()` method, passing the target element as a parameter. The `[name]TargetDisconnected()` lifecycle callbacks will fire *before* the controller's `disconnect()` callback.
When a target becomes disconnected, Stimulus calls its controller's `[name]TargetDisconnected()` method, passing the target element as a parameter. The `[name]TargetDisconnected()` lifecycle callbacks will fire *after* the controller's `disconnect()` callback.

## Reconnection

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ removed within the controller's element.

Define a method `[name]TargetConnected` or `[name]TargetDisconnected` in the controller, where `[name]` is the name of the target you want to observe for additions or removals. The method receives the element as the first argument.

Stimulus invokes each element callback any time its target elements are added or removed after `connect()` and before `disconnect()` lifecycle hooks.
Stimulus invokes each element callback any time its target elements are added or removed. When the controller is connected or disconnected from the document, these callbacks are invoked *before* `connect()` and *after* `disconnect()` lifecycle hooks.

```js
export default class extends Controller {
Expand Down Expand Up @@ -130,6 +130,6 @@ Always use camelCase to specify target names, since they map directly to propert

```js
export default class extends Controller {
static targets = [ "camelCase" ]
static targets = [ "camelCase" ]
}
```

0 comments on commit f3dff4a

Please sign in to comment.