angular / angular

Deliver web apps with confidence 🚀
https://angular.dev
MIT License
96.37k stars 25.57k forks source link

Support configuration of attachShadow when Custom Elements are created #57042

Open minchal opened 4 months ago

minchal commented 4 months ago

Which @angular/* package(s) are relevant/related to the feature request?

elements, platform-browser

Description

When Custom Elements instances are created (using @angular/elements) deep in the stack DOM's attachShadow method of host element is called: https://github.com/angular/angular/blob/main/packages/platform-browser/src/dom/dom_renderer.ts#L424

I would like to inject additional configuration (right now only the default mode: open is used), specifically the serializable: true property, but there might be more use-cases for other config properties: https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow#serializable

Proposed solution

Allow to pass this config through Injector or as createCustomElement configuration.

Alternatives considered

Make it possible or simplify to extend and override class of ShadowDomRenderer used internally by DomRendererFactory2.

AndreasLoukakis commented 1 month ago

This might also provide a solution for #44110 scoped element registries