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
[reactive-element] Normalize adoptStyles
so that it works x-browser when called to modify instance styles
#3010
Comments
Adds ability to add to an existing set of styles via adoptStyles. Fixes #3010.
We've decided not to address this issue. On browsers that support However, it looks like Safari support will be added soon, see WebKit/WebKit#4872. Given that and the code size impact of #3060, we've elected to wait for native support. |
It was unclear to me if lit did support import style from './style.css' assert { type: 'css' }
class NameTag extends LitElement {
static styles = style
} but it was able to understand it. i guess the example confused me a bit as to why your example was more like: import {LitElement, css} from 'lit'
export class MyElement extends LitElement {
static styles = css`p { color: green; }`
} i think that the example should be like have been more like the constructible CSSStyleSheet. import { LitElement } from 'lit'
const css = new CSSStyleSheet()
css.replaceSync(`p { color: green; }`)
export class MyElement extends LitElement {
static styles = css
} (or as the first example at the very top) |
ReactiveElement supports static styles that are not modified per instance. This was done so that support for Web Components polyfilled styling via ShadyCSS (which does not support instance styling) would work. The
adoptStyles
function was designed for this use case.However, now that a significant portion of users do not need Web Components polyfills, it's reasonable to start introducing better instance based styling. Currently
adoptStyles
works inconsistently when the underlyingadoptedStylesheets
is supported or not. This behavior should be normalized so that it works the same x-browser when native Shadow DOM is used.Separately, users have asked for a way to add styles rather than re-apply them. This could be done as a separate method or an alternative signature.
The text was updated successfully, but these errors were encountered: