lit / lit/lit.dev

Inconsistent order around disconnectedCallback()

Open
#1,105 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
142
Forks
230
PR merge metrics
No merged PRs in 30d

Description

Between two docs pages I see inconsistent documentation around the order of calls surrounding `super.disconnectedCallback()`.

On the [lifecycle](https://lit.dev/docs/components/lifecycle/#disconnectedcallback) docs. I see the super call come before other code is run:
```
disconnectedCallback() {
super.disconnectedCallback()
window.removeEventListener('keydown', this._handleKeydown);
}
```

On the [events](https://lit.dev/docs/components/events/#adding-event-listeners-to-other-elements) docs. I see the super call come after other code is run:
```
disconnectedCallback() {
window.removeEventListener('resize', this._handleResize);
super.disconnectedCallback();
}
```

Is there a correct order? My assumption given the context is that the _super_ call should be made at the very end of the callback.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare the `disconnectedCallback()` examples in the lifecycle and events documentation pages linked in the issue. Determine the correct order for the `super` call, update both examples consistently, and verify that the surrounding guidance matches the chosen order.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.