Skip to content

Commit 7bcb656

Browse files
committed
fix: warn when static styles used with light DOM (silently ignored before)
static styles + static shadow = false is a mistake — adoptedStyleSheets requires a shadow root. Now logs a clear warning telling the developer to use global CSS or <style> in render() instead.
1 parent d74daa8 commit 7bcb656

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

packages/core/src/component.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,15 @@ export class WebComponent extends Base {
359359
if (list.length) adoptStyles(this._renderRoot, list);
360360
} else {
361361
this._renderRoot = this;
362-
// Light DOM: inject scoped styles as a <style> element if not already present.
363-
// Light DOM: no style injection. `static styles` is for shadow DOM.
364-
// Light DOM components use global CSS, Tailwind, or inline <style>
365-
// in their render() template.
362+
// Light DOM: static styles is not supported (no shadow root for
363+
// adoptedStyleSheets). Warn if the developer set both.
364+
if (Ctor.styles) {
365+
console.warn(
366+
`[webjs] <${Ctor.tag}> has static shadow = false AND static styles. ` +
367+
`static styles only works with shadow DOM (adoptedStyleSheets). ` +
368+
`For light DOM, use global CSS or <style> in render().`
369+
);
370+
}
366371
}
367372

368373
// Notify all controllers that the host is connected.

0 commit comments

Comments
 (0)