Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid triggering connected callback from disconnected callback (#…
…4718) When moving an element that extends from `DirMixin` in the DOM, the `DirMixin.disconnectedCallback` can trigger the element's `connectedCallback` before the `disconnectedCallback` has finished (currently reproducable in Chrome, FF). That can cause elements to re-run their initialization logic before their cleanup logic is finished. For example in case of the `AppLayout`, this results in the `connectedCallback` adding several event listeners again, after which the remaining logic in `disconnectedCallback` removes them again, leaving the element in a state where the listeners are not registered. See #4682 (comment). This change removes the `removeAttribute` call from `DirMixin.disconnectedCallback` that causes the premature reconnect, and instead introduces a flag that ensures that the element will subscribe to global dir changes again on reconnect. This also fixes a minor bug where the custom dir of an element was removed on disconnect (see test case). Fixes: #4682
- Loading branch information