fix(core): do not clear element content when using shadow dom (#24861)
PR Close #24861
This commit is contained in:

committed by
Misko Hevery

parent
1f59f2f04d
commit
6e828bba88
@ -135,13 +135,15 @@ class DefaultDomRenderer2 implements Renderer2 {
|
||||
}
|
||||
}
|
||||
|
||||
selectRootElement(selectorOrNode: string|any): any {
|
||||
selectRootElement(selectorOrNode: string|any, preserveContent?: boolean): any {
|
||||
let el: any = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
|
||||
selectorOrNode;
|
||||
if (!el) {
|
||||
throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
|
||||
}
|
||||
el.textContent = '';
|
||||
if (!preserveContent) {
|
||||
el.textContent = '';
|
||||
}
|
||||
return el;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user