fix(slotmixin): now prints console error when shadowRoot is not found

This commit is contained in:
Dozom 2024-05-21 16:20:07 +02:00 committed by GitHub
parent def3df4c08
commit 08d13e1a30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/ui': patch
---
Now prints console error when shadowRoot is not found

View file

@ -131,7 +131,13 @@ const SlotMixinImplementation = superclass =>
if (isFirstRender) {
// @ts-expect-error wait for browser support
const supportsScopedRegistry = !!ShadowRoot.prototype.createElement;
const registryRoot = supportsScopedRegistry ? this.shadowRoot || document : document;
const hasShadowRoot = Boolean(this.shadowRoot);
if (!hasShadowRoot) {
// TODO: throw an error in a breaking release
// eslint-disable-next-line no-console
console.error(`[SlotMixin] No shadowRoot was found`);
}
const registryRoot = supportsScopedRegistry ? this.shadowRoot : document;
// @ts-expect-error wait for browser support
const renderTargetThatRespectsShadowRootScoping = registryRoot.createElement('div');