Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Setup the shadow root if it hasn't been setup yet.
if (!sr) {
if (shadowDomV1) {
sr = elem.attachShadow({ mode: 'open' });
} else if (shadowDomV0) {
sr = elem.createShadowRoot();
} else {
sr = elem;
}
elem[$shadowRoot] = sr;
}
if (shouldRender) {
patchInner(sr, () => {
const possibleFn = render(elem);
if (typeof possibleFn === 'function') {
possibleFn();
} else if (Array.isArray(possibleFn)) {
possibleFn.forEach((fn) => {
if (typeof fn === 'function') {
fn();
}
});
}
});
if (rendered) {
rendered(elem);
}
}
rendererCallback () {
if (!this.shadowRoot) {
this.attachShadow({ mode: 'open' });
}
patchInner(this.shadowRoot, () => {
const possibleFn = this.renderCallback(this);
if (isFunction(possibleFn)) {
possibleFn();
} else if (Array.isArray(possibleFn)) {
possibleFn.forEach((fn) => {
if (isFunction(fn)) {
fn();
}
});
}
});
}