Skip to content

Commit 6e541db

Browse files
committed
chore: warn style injection in shadowRoot: false mode
1 parent e94b01b commit 6e541db

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/runtime-dom/src/apiCustomElement.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ export class VueElement extends BaseClass {
312312
}
313313

314314
// apply CSS
315+
if (__DEV__ && styles && def.shadowRoot === false) {
316+
warn(
317+
'Custom element style injection is not supported when using ' +
318+
'shadowRoot: false',
319+
)
320+
}
315321
this._applyStyles(styles)
316322

317323
// initial render
@@ -481,11 +487,13 @@ export class VueElement extends BaseClass {
481487
}
482488

483489
private _applyStyles(styles: string[] | undefined) {
490+
const root = this.shadowRoot
491+
if (!root) return
484492
if (styles) {
485493
styles.forEach(css => {
486494
const s = document.createElement('style')
487495
s.textContent = css
488-
this._root.appendChild(s)
496+
root.appendChild(s)
489497
// record for HMR
490498
if (__DEV__) {
491499
;(this._styles || (this._styles = [])).push(s)

0 commit comments

Comments
 (0)