Skip to content

in-element helper doesn't fire destroy hooks on children when destinationElement is removed from DOM #20710

Open
@apellerano-pw

Description

@apellerano-pw

🐞 Describe the Bug

If there are elements nested inside an in-element helper, they get rendered to a remote element defined by destinationElement. If this remote element is removed from the DOM, the elements nested inside the in-element helper are destroyed. However, their destroy hooks are not triggered.

This can cause leakage and stale reference exceptions to occur, because modifier and component destroy hooks did not get a chance to do cleanup.

🔬 Minimal Reproduction

Glimdown reproduction

😕 Actual Behavior

  • The destroy function for the modifier is not called.
  • The destroy hook for the component is not called.

🤔 Expected Behavior

  • The destroy function for the modifier is called.
  • The destroy hook for the component is called.

🌍 Environment

  • Ember: - I've reproduced this going back to Ember 3.28.12
  • Ember-CLI: - 3.28.6
  • Node.js/npm: - Node 18.20.0, npm 10.5.0
  • OS: - macOS 14.5 Sonoma
  • Browser: - Chrome 126.0.6478.127 (Official Build) (x86_64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions