Closed jarrodek closed 4 years ago
Using <style>${this.styles}</style>
is not supported and also not needed. See lit-element documentation, you need to make your styles property static get styles() { ... }
and it'll just work.
Beyond this if you REALLY must use create the style as you have here then it requires additional effort to prevent attempts to minify the <style>${this.styles}<style>
code:
import { html, css, LitElement } from 'lit-element';
class Element extends LitElement {
get styles() {
return css`...`;
}
render() {
const htmlNoMin = html;
const style = htmlNoMin`<style>${this.styles}<style>`;
return html`${style} ...`;
}
}
Like I said, there's a valid reason for that :) I am aware of the styling API for lit element. Mind that putting a style tag inside a component's shadow root is a valid approach.
Thanks for a possible walk around.
Yeah the thing is having <style>
with dynamic content cannot be supported by the underlying libraries which actually minify. Might be possible to use bindings for certain css values like content: "${content}"
but most likely only quoted values.
I have the following configuration:
Then in the components, for some valid reasons, I am using styles defined as follows:
This causes an error like this:
For now I will disable css minification as then it start working again but it would be nice to have this working.