Skip to content

Commit 222e643

Browse files
authored
Merge pull request #760 from zacheryph/fix/lifecycle-callback-ordering
Fix Inconsistency with Callback Ordering (#759)
2 parents fd60fc9 + f3dff4a commit 222e643

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/reference/lifecycle_callbacks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ A connected target will later become _disconnected_ when either of the preceding
7171
* the element's `data-{identifier}-target` attribute is removed or modified
7272
* the document installs a new `<body>` element, such as during a Turbo page change
7373

74-
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.
74+
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.
7575

7676
## Reconnection
7777

docs/reference/targets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ removed within the controller's element.
9595

9696
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.
9797

98-
Stimulus invokes each element callback any time its target elements are added or removed after `connect()` and before `disconnect()` lifecycle hooks.
98+
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.
9999

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

131131
```js
132132
export default class extends Controller {
133-
static targets = [ "camelCase" ]
133+
static targets = [ "camelCase" ]
134134
}
135135
```

0 commit comments

Comments
 (0)