Skip to content

Commit 01b55c2

Browse files
committed
feat: default components to light DOM, shadow DOM is opt-in
Change static shadow default from true to false. Components now render to light DOM by default. Set static shadow = true to opt into shadow DOM with adoptedStyleSheets.
1 parent 893c99f commit 01b55c2

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/core/src/component.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ export class WebComponent extends Base {
120120
/** Custom element tag name. Subclasses must override. @type {string} */
121121
static tag = '';
122122

123-
/** Whether to use shadow DOM. @type {boolean} */
124-
static shadow = true;
123+
/** Whether to use shadow DOM. Default: false (light DOM). @type {boolean} */
124+
static shadow = false;
125125

126126
/**
127127
* Hydration strategy for this component.
@@ -349,7 +349,7 @@ export class WebComponent extends Base {
349349
_activate() {
350350
this._connected = true;
351351
const Ctor = /** @type any */ (this.constructor);
352-
if (Ctor.shadow !== false) {
352+
if (Ctor.shadow === true) {
353353
const hadSSRShadow = !!this.shadowRoot;
354354
if (!this.shadowRoot) {
355355
/** @type any */ (this).attachShadow({ mode: 'open' });

packages/core/src/render-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ async function injectDSD(html, ctx) {
248248
if (ctx && ctx.usedComponents) ctx.usedComponents.add(tag);
249249
const opening = selfClose ? `<${tag}${attrs}>` : match;
250250
try {
251-
const isShadow = /** @type any */ (Cls).shadow !== false;
251+
const isShadow = /** @type any */ (Cls).shadow === true;
252252
const instance = new /** @type any */ (Cls)();
253253
const attrMap = parseAttrs(attrs);
254254
applyAttrsToInstance(instance, attrMap, Cls);

0 commit comments

Comments
 (0)