-
Notifications
You must be signed in to change notification settings - Fork 10
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
website home page banner briefly flashing inline styles as text on page load when prerendering (SSG / MPA) #752
Comments
Yeah, did some more investigating and it seems related to usage of For example. if I do this for the header, eg. import { css, html, LitElement, unsafeCSS } from 'lit';
import headerCss from './header.css?type=css';
class HeaderComponent extends LitElement {
.
.
.
render() {
const { navigation } = this;
return html`
<style>
${headerCss}
</style>
<header class="header">
...
</header>
`;
}
}
customElements.define('app-header', HeaderComponent); The same thing happens as on the home page The thing that seems to make it better in all, and is recommended by Lit, is to use import { css, html, LitElement, unsafeCSS } from 'lit';
import headerCss from './header.css?type=css';
class HeaderComponent extends LitElement {
.
.
.
static get styles() {
return css`
${unsafeCSS(headerCss)}
`;
}
render() {
const { navigation } = this;
return html`
<header class="header">
...
</header>
`;
}
}
customElements.define('app-header', HeaderComponent); |
So while I can't pinpoint exactly why Lit is failing in this way, from reading I was able to do from the links in my previous comment, in certain scenarios, depending on the level of nesting of ShadowDOM, ShadyDOM might fall apart when using this variant of Lit and combined with using expressions? import someCss from './some.css';
.
.
render() {
return html`
<style>
${someCss}
</style>
...
`;
} It seems that doing this is fine though import someCss from './some.css';
.
.
render() {
return html`
<style>
:host {
p {
color: red;
}
}
</style>
...
`;
} However, using Lit's get styles() {
return css`
${unsafeCSS(eveButtonCss)}
`;
} I am happy if puppeteer at least supports the standard Will open a PR to vendor a hot fix for now just to fix up the home page, and will dig more into this during our next Project, which coincidentally will be focused on SSR. 🤞 |
Not sure if this release from lit-html would help with anything here? |
closing this out for now but will keep around for tracking as part of the SSR related work. |
Type of Change
Summary
It appears that after merging #611 I noticed that something's inline Shadow DOM styles are briefly flickering on load 😱
https://user-images.githubusercontent.com/895923/136285238-87fe8ea7-f688-4111-9807-146bba56277e.mov
Details
Does seem to be related to
<eve-button>
based on the source contents being displayed. It is currently being used in the banner component.I don't recall seeing it before in that branch, so a few things to try
<eve-button>
(mainly just validate root cause)lit@2
#611Wonder if it's a
<slot>
/ Light DOM thing? I don't see it happening anywhere else on the site though... maybe because everything else hasdata-gwd-opt="static"
?The text was updated successfully, but these errors were encountered: