Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CSSStyleSheet for .styles property #774

Closed
samthor opened this issue Aug 14, 2019 · 3 comments · Fixed by #853
Closed

Support CSSStyleSheet for .styles property #774

samthor opened this issue Aug 14, 2019 · 3 comments · Fixed by #853

Comments

@samthor
Copy link
Contributor

samthor commented Aug 14, 2019

lit-element should support returning a CSSStyleSheet object from the static class getter .styles(), in order to support the upcoming CSS Modules spec.

This behavior should be supported:

import styles from './my-element.css';

class MyElement extends LitElement {
  static get styles() { return [styles]; }
}

Currently, I can do this, but it's using browser support only:

import styles from './my-element.css';

class MyElement extends LitElement {
  constructor() {
    super();

    // Lit doesn't clobber this, since it has zero styles
    this.shadowRoot.adoptedStyleSheets = [styles];
  }
}
@danielbarion
Copy link
Contributor

Take a look: #747

Maybe this can help you...

@samthor
Copy link
Contributor Author

samthor commented Aug 19, 2019

@danielbarion that's not related. I don't have the raw string, CSS Modules gives you a parsed CSSStyleSheet.

@grvpanchal
Copy link

Can we have ability to modify LitElement.styles as we dynamically load styles?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants