An cache for created SophistryStyleSheets.
Import a stylesheet defined in an external CSS file. Optionally specify a name for the imported style in the Scophystry context (cache). The name will default to the portion of the link before the first apostrophe...
Optional
name: stringconst style = mySophistry.import('style.css');
Processes and 'pops' all style tags within the root. Ensures that the same CSSStyleSheet can be reused across document trees (maindocument and shadow roots) instead of duplicated even when they have been created declaratively.
If replace is truthy, any cached stylesheets with the same name (or hash) as a styleshhet within the root will be replaced (reactively).
This resolves the stated issue with declaratively adding encapsulated styles to elements when using shadow DOM as described here; https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM.
Optional
replace: booleanconst element = apriori.createFragment(apriori.get('markup.html'));
const styles = mySophistry.process(element);
document.body.append(element);
for (let style of styles) style.style(element, document.body.firstElementChild);
Replaces the text of an existing stylesheet. This is reactive.
mySophistry.set('style.css', await apriori.get('new-style.css')); // override everything.
An instance of Sophistrory can be used to obtain and cache CSS Stylesheets which can be shared by multiple DOM elements.
Example