Skip to content

feat(cdk Portal): Allow DomPortal to reference detached elements #34023

Open

Description

@Gouvernathor

Feature Description

There is a built-in security that blocks a detached element (one that has no parent node) to be used in a DomPortal, here.
The only purpose of this bit of code is to ensure that if the DOM node is obtained the nominal way, i.e from the component's view, then it gets put back where it was before, when the operation is done or it stops being used.

Use Case

I have a dependency that generates DOM nodes (SVG nodes to be precise). I was using a custom directive that was using inject(ElementRef).nativeElement and .replaceChildren(this.inputDOMNode()), which works but is not great.

I discovered Portal and thought I could use it, but I actually can't because the built-in security prevents me from passing a detached element to DOMPortal(). I guess I could instanciate a dummy DOM node (itself detached) to attach all my SVG nodes to it before passing them to the DOMPortal, but that's nonsense really, I just don't need the housekeeping feature of placing the node back where it was found.

Activity

  1. added
    feature
    needs triage
    on Oct 29, 2026
  2. added
    gemini-triaged
    on Oct 29, 2026
  3. added
    P4
    and removed
    needs triage
    gemini-triaged
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4area: cdk/portalfeature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions