@fluid-topics/ft-wc-utils
Advanced tools
Comparing version 1.1.52 to 1.1.53
@@ -11,2 +11,3 @@ import { PropertyValues } from "lit"; | ||
private adoptedCustomStyleSheet; | ||
private useAdoptedStyleSheets; | ||
private readonly [constructorPrototype]; | ||
@@ -19,2 +20,3 @@ private readonly [constructorName]; | ||
protected contentAvailableCallback(props: PropertyValues): void; | ||
private applyCustomStylesheet; | ||
private [exportpartsDebouncer]; | ||
@@ -21,0 +23,0 @@ private scheduleExportpartsUpdate; |
@@ -19,2 +19,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
this.adoptedCustomStyleSheet = new CSSStyleSheet(); | ||
this.useAdoptedStyleSheets = true; | ||
this[_a] = new Debouncer(5); | ||
@@ -31,14 +32,17 @@ this[constructorName] = this.constructor.name; | ||
super.connectedCallback(); | ||
if (this.shadowRoot && !this.shadowRoot.adoptedStyleSheets.includes(this.adoptedCustomStyleSheet)) { | ||
this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, this.adoptedCustomStyleSheet]; | ||
try { | ||
if (this.shadowRoot && !this.shadowRoot.adoptedStyleSheets.includes(this.adoptedCustomStyleSheet)) { | ||
this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, this.adoptedCustomStyleSheet]; | ||
} | ||
} | ||
catch (e) { | ||
this.useAdoptedStyleSheets = false; | ||
console.error("Cannot use adopted stylesheets", e); | ||
} | ||
} | ||
updated(props) { | ||
var _b; | ||
super.updated(props); | ||
if (props.has("customStylesheet")) { | ||
this.adoptedCustomStyleSheet.replace((_b = this.customStylesheet) !== null && _b !== void 0 ? _b : ""); | ||
} | ||
this.updateComplete.then(() => { | ||
this.contentAvailableCallback(props); | ||
this.applyCustomStylesheet(props); | ||
this.scheduleExportpartsUpdate(); | ||
@@ -49,2 +53,24 @@ }); | ||
} | ||
applyCustomStylesheet(props) { | ||
var _b, _c, _d; | ||
if (this.useAdoptedStyleSheets) { | ||
if (props.has("customStylesheet")) { | ||
try { | ||
this.adoptedCustomStyleSheet.replaceSync((_b = this.customStylesheet) !== null && _b !== void 0 ? _b : ""); | ||
} | ||
catch (e) { | ||
console.error(e, this.customStylesheet); | ||
} | ||
} | ||
} | ||
else { | ||
((_d = (_c = this.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelectorAll(".ft-lit-element--custom-stylesheet")) !== null && _d !== void 0 ? _d : []).forEach(e => e.remove()); | ||
if (this.customStylesheet) { | ||
const customStyles = document.createElement("style"); | ||
customStyles.classList.add("ft-lit-element--custom-stylesheet"); | ||
customStyles.innerHTML = this.customStylesheet; | ||
this.shadowRoot.append(customStyles); | ||
} | ||
} | ||
} | ||
scheduleExportpartsUpdate() { | ||
@@ -51,0 +77,0 @@ var _b, _c, _d; |
{ | ||
"name": "@fluid-topics/ft-wc-utils", | ||
"version": "1.1.52", | ||
"version": "1.1.53", | ||
"description": "Internal web components tools", | ||
@@ -27,3 +27,3 @@ "author": "Fluid Topics <devtopics@antidot.net>", | ||
}, | ||
"gitHead": "8b2c90df3e7d82be373f6e963272a37ebf57b017" | ||
"gitHead": "9533374bb075edb940b4426a00561f27c34d2f01" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84997
1720