Review main Merged

92538[BUGFIX] Fix leaking event handlers in content-navigation-toggle

Benjamin Franzke CR +2 V +2 Easy +14 −4 updated 01/28/26, 08:22

Commit message

`<content-navigation-toggle>` (when run inside an iframe) attaches event
handlers to the top level document, causing the top-document event
handler to hold a reference to the DOM element from the current iframe,
which itself holds a reference to the `document` object of the frame,
causing all available DOM elements to be kept in memory for the
lifetime of the current session, even if the iframe is no longer active
and a new iframe location has been navigated to.

Note that `disconnectedCallback()` of custom elements is only triggered
when an element is disconnected from the current DOM, but not when the
entire page (iframe) is about to be "hidden", therefore we need to
additionally cleanup our cross-document event handlers in the `pagehide`
event. Ideally we'd avoid registering event listeners to cross-frame
documents, but that will require further refactorings and `pagehide`
helps to mitigate the memory leak.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Oli Bartsch +1
    • Andreas Kienast +1
    • Benjamin Kott +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Oli Bartsch +1
    • Andreas Kienast +1
    • Benjamin Kott +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 1013

  1. Benjamin Franzke uploaded patch set 1 01/27/26, 16:25

  2. core-ci voted on patch set 1 V +1 01/27/26, 16:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94435

  3. Benjamin Franzke uploaded patch set 2 V +1 01/27/26, 16:48

  4. core-ci voted on patch set 2 V +1 01/27/26, 16:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94438

  5. Andreas Kienast commented on patch set 2 01/28/26, 06:56

    content-navigation-toggle.ts:69

    Why do we need this – or: in which case is `disconnectedCallback` not called?
  6. Benjamin Franzke rebased onto patch set 3 V +1 01/28/26, 07:24

  7. Benjamin Franzke commented on patch set 3 01/28/26, 07:25

    content-navigation-toggle.ts:69 Reply

    Thanks that's a good question, so I updated the commit message to explain that. https://review.typo3.org/c/Packages/TYPO3.CMS/+/92538/2..3//COMMIT_MSG Fine with you?
  8. core-ci voted on patch set 3 V +1 01/28/26, 07:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94478

  9. Benjamin Kott voted on patch set 3 CR +1 V +1 01/28/26, 07:47

  10. Oli Bartsch voted on patch set 3 CR +1 V +1 01/28/26, 07:50

  11. Andreas Kienast commented on patch set 3 CR +1 V +1 01/28/26, 08:18

    content-navigation-toggle.ts:69 Reply

    Ack, thanks.
  12. Benjamin Franzke voted on patch set 3 CR +2 V +2 01/28/26, 08:22

  13. Benjamin Franzke merged patch set 4 01/28/26, 08:22