Skip to content

Commit

Permalink
Add option for adopted style sheets
Browse files Browse the repository at this point in the history
  • Loading branch information
coolavery committed Apr 20, 2022
1 parent 5790765 commit 7c4d1bd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default function register(Component, tagName, propNames, options) {
inst._vdomComponent = Component;
inst._root =
options && options.shadow ? inst.attachShadow({ mode: 'open' }) : inst;
inst._options = options;
return inst;
}
PreactElement.prototype = Object.create(HTMLElement.prototype);
Expand Down Expand Up @@ -81,6 +82,15 @@ function connectedCallback() {
{ ...this._props, context },
toVdom(this, this._vdomComponent)
);

// Apply adopted style sheets
if (this._options.adoptedStyleSheets && this._vdom) {
this._vdom.adoptedStyleSheets = [
...this._vdom.adoptedStyleSheets,
...this._options.adoptedStyleSheets,
];
}

(this.hasAttribute('hydrate') ? hydrate : render)(this._vdom, this._root);
}

Expand Down

0 comments on commit 7c4d1bd

Please sign in to comment.