feat(core): add support for ShadowDOM v1 (#24718)
add a new ViewEncapsulation.ShadowDom option that uses the v1 Shadow DOM API to provide style encapsulation. PR Close #24718
This commit is contained in:

committed by
Miško Hevery

parent
1ae3f87383
commit
3553977bd7
@ -83,6 +83,7 @@ export class DomRendererFactory2 implements RendererFactory2 {
|
||||
return renderer;
|
||||
}
|
||||
case ViewEncapsulation.Native:
|
||||
case ViewEncapsulation.ShadowDom:
|
||||
return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
|
||||
default: {
|
||||
if (!this.rendererByCompId.has(type.id)) {
|
||||
@ -256,7 +257,11 @@ class ShadowDomRenderer extends DefaultDomRenderer2 {
|
||||
eventManager: EventManager, private sharedStylesHost: DomSharedStylesHost,
|
||||
private hostEl: any, private component: RendererType2) {
|
||||
super(eventManager);
|
||||
this.shadowRoot = (hostEl as any).createShadowRoot();
|
||||
if (component.encapsulation === ViewEncapsulation.ShadowDom) {
|
||||
this.shadowRoot = (hostEl as any).attachShadow({mode: 'open'});
|
||||
} else {
|
||||
this.shadowRoot = (hostEl as any).createShadowRoot();
|
||||
}
|
||||
this.sharedStylesHost.addHost(this.shadowRoot);
|
||||
const styles = flattenStyles(component.id, component.styles, []);
|
||||
for (let i = 0; i < styles.length; i++) {
|
||||
|
Reference in New Issue
Block a user