Skip to content

Commit b44fc3d

Browse files
committed
support style arrays
1 parent 5de94e6 commit b44fc3d

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"description": "Base Custom Webcomponent",
33
"name": "@node-projects/base-custom-webcomponent",
4-
"version": "0.22.0",
4+
"version": "0.23.0",
55
"type": "module",
66
"main": "./dist/index.js",
77
"author": "",
@@ -10,7 +10,7 @@
1010
"tsc": "tsc"
1111
},
1212
"devDependencies": {
13-
"typescript": "^5.3.2"
13+
"typescript": "^5.3.3"
1414
},
1515
"repository": {
1616
"type": "git",

src/BaseCustomWebComponent.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type repeatBindingItem = { name: string, item: any }
8080
let _bindingRegex = /\[\[.*?\]\]/g;
8181

8282
export class BaseCustomWebComponentNoAttachedTemplate extends HTMLElement {
83-
static readonly style: CSSStyleSheet | Promise<CSSStyleSheet>;
83+
static readonly style: CSSStyleSheet | Promise<CSSStyleSheet> | CSSStyleSheet[];
8484
static readonly template: HTMLTemplateElement;
8585

8686
//todo: bindings map should contain the name of the bound property
@@ -648,14 +648,18 @@ export class BaseCustomWebComponentNoAttachedTemplate extends HTMLElement {
648648
this.shadowRoot.adoptedStyleSheets = [style];
649649
//@ts-ignore
650650
} else if (this.constructor.style) {
651-
652651
//@ts-ignore
653-
if (this.constructor.style instanceof Promise)
654-
//@ts-ignore
655-
this.constructor.style.then((style) => this.shadowRoot.adoptedStyleSheets = [style]);
656-
else
652+
if (this.constructor.style instanceof CSSStyleSheet) {
657653
//@ts-ignore
658654
this.shadowRoot.adoptedStyleSheets = [this.constructor.style];
655+
//@ts-ignore
656+
} else if (Array.isArray(this.constructor.style)) {
657+
//@ts-ignore
658+
this.shadowRoot.adoptedStyleSheets = this.constructor.style;
659+
//@ts-ignore
660+
} else if (this.constructor.style instanceof Promise)
661+
//@ts-ignore
662+
this.constructor.style.then((style) => this.shadowRoot.adoptedStyleSheets = [style]);
659663
}
660664

661665
//@ts-ignore

0 commit comments

Comments
 (0)