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

Export injectStyles so the polyfill can work with Lit #200

Closed
Totati opened this issue Apr 26, 2024 · 1 comment
Closed

Export injectStyles so the polyfill can work with Lit #200

Totati opened this issue Apr 26, 2024 · 1 comment

Comments

@Totati
Copy link
Contributor

Totati commented Apr 26, 2024

Hi, we
This polyfill does not work well with Lit, as Lit overrides the adoptedStyleSheets in the first connectedCallback.

Currently I could overcome this by overriding the Lit's ReactiveElement#createRenderRoot with a custom implementation, so it spreads the current adopted styles, but it's not a patch.

When injectStyles is exported it can be patched with way less code, keeping the original implementation.

  const originalCreateRenderRoot = (ReactiveElement as any).prototype.createRenderRoot;
  (ReactiveElement as any).prototype.createRenderRoot = function () {
    const renderRoot = originalCreateRenderRoot.call(this);
    injectStyles(renderRoot);
    return renderRoot;
  };
@jgerigmeyer
Copy link
Member

@Totati Thanks for reporting! This is released in v0.4.3.

jgerigmeyer added a commit that referenced this issue Apr 29, 2024
jgerigmeyer added a commit that referenced this issue Apr 29, 2024
* main:
  v0.4.3
  do not error if `window` is undefined
  Export injectStyles -- fixes #200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants