@vaadin/vaadin-themable-mixin
Advanced tools
Comparing version 21.0.0-alpha0.b163d3a8c to 21.0.0-alpha1
{ | ||
"name": "@vaadin/vaadin-themable-mixin", | ||
"version": "21.0.0-alpha0.b163d3a8c", | ||
"version": "21.0.0-alpha1", | ||
"description": "vaadin-themable-mixin", | ||
@@ -37,3 +37,3 @@ "main": "vaadin-themable-mixin.js", | ||
}, | ||
"gitHead": "e1ed53b0be7b77493e3a23a076f4e47c16674dbd" | ||
"gitHead": "8542c7dadc4c86e454a48613f0f2d027dcb5aa86" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { CSSResult } from 'lit'; | ||
import { CSSResultGroup } from 'lit'; | ||
@@ -9,8 +9,4 @@ export { css, unsafeCSS } from 'lit'; | ||
*/ | ||
declare function registerStyles( | ||
themeFor: String | null, | ||
styles: CSSResult | Array<CSSResult | null> | null, | ||
options?: object | null | ||
): void; | ||
declare function registerStyles(themeFor: string | null, styles: CSSResultGroup, options?: object | null): void; | ||
export { registerStyles }; |
import '@polymer/polymer/lib/elements/dom-module.js'; | ||
import { CSSResult } from 'lit'; | ||
import { stylesFromTemplate } from '@polymer/polymer/lib/utils/style-gather.js'; | ||
export { css, unsafeCSS } from 'lit'; | ||
@@ -14,3 +15,3 @@ | ||
* @param {String} themeFor The local/tag name of the component type to register the styles for | ||
* @param {CSSResult | CSSResult[]} styles The CSS style rules to be registered for the component type | ||
* @param {CSSResultGroup} styles The CSS style rules to be registered for the component type | ||
* matching themeFor and included in the local scope of each component instance | ||
@@ -27,3 +28,3 @@ * @param {Object=} options Additional options | ||
styles.forEach((cssResult) => { | ||
const processedStyles = styles.map((cssResult) => { | ||
if (!(cssResult instanceof CSSResult)) { | ||
@@ -33,13 +34,9 @@ throw new Error('An item in styles is not of type CSSResult. Use `unsafeCSS` or `css`.'); | ||
if (!styleMap[cssResult]) { | ||
const styleModuleElement = document.createElement('dom-module'); | ||
styleModuleElement.innerHTML = ` | ||
<template> | ||
<style>${cssResult.toString()}</style> | ||
</template> | ||
`; | ||
const template = document.createElement('template'); | ||
template.innerHTML = `<style>${cssResult.toString()}</style>`; | ||
const styleId = `custom-style-module-${moduleIdIndex++}`; | ||
styleModuleElement.register(styleId); | ||
styleMap[cssResult] = styleId; | ||
styleMap[cssResult] = stylesFromTemplate(template)[0]; | ||
} | ||
return styleMap[cssResult].textContent; | ||
}); | ||
@@ -64,3 +61,3 @@ | ||
${moduleIncludes.map((include) => `<style include=${include}></style>`)} | ||
${styles.map((style) => `<style include=${styleMap[style]}></style>`)} | ||
${processedStyles.length ? `<style>${processedStyles.join('\n')}</style>` : ''} | ||
</template> | ||
@@ -67,0 +64,0 @@ `; |
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
41568
204