Review 12.4 Merged

89202[BUGFIX] Check state in web components extending `HTMLElement`

Andreas Kienast CR +2 V +2 Normal +55 −10 updated 05/21/25, 07:28

Commit message

Web components that extend `HTMLElement` directly suffer from poor
lifecycles as `connectedCallback()` is called when the component is
added into the DOM, and when it is moved. This causes several issues,
e.g. double initialization or stacked event listeners.

This is a major issue in FormEngine as IRRE elements may get re-ordered
and thus the position of their children change in the DOM, calling
`connectedCallback()` again.

To solve this issue in FormEngine context for now, internal state is
checked and futher processing is aborted, if suitable.

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
  • Verified V +2 Done
    • Andreas Kienast +2
    • core-ci +1 CI

Issues 1

Files 18

Review log 67

  1. Andreas Kienast uploaded patch set 1 04/23/25, 10:53

  2. core-ci voted on patch set 1 V +1 04/23/25, 10:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78061

  3. Oli Bartsch commented on patch set 1 04/24/25, 19:44

    So should we also move event listener definition into the constructor, according to https://hawkticehurst.com/2023/11/you-are-probably-using-connectedcallback-wrong/
  4. Andreas Kienast commented on patch set 1 04/25/25, 05:24

    Reply

    This sounds feasible. We must be extremely careful to do this only for event listeners bound to the web component directly (as stated in the article as well). Since this is an unmerged backport, I opt to start a new patch.
  5. Oli Bartsch commented on patch set 1 04/28/25, 15:24

    Reply

    Acknowledged
  6. Andreas Kienast voted on patch set 1 CR +2 V +2 05/21/25, 07:28

  7. Andreas Kienast merged patch set 2 05/21/25, 07:28