-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Labels
Contributions WelcomeIssues that we would accept a PR forIssues that we would accept a PR for
Description
Description
When using Lit SSR and enabling createRenderRoot for a custom element, Lit is rendering the content inside declarative shadow DOM <template> tag.
Steps to Reproduce
- Given the sample Greeting component that uses
createRenderRootimport { html, css, LitElement } from 'lit'; export class SimpleGreeting extends LitElement { static styles = css`p { color: blue }`; static properties = { name: {type: String}, }; constructor() { super(); this.name = 'Somebody'; } createRenderRoot(){ return this; } render() { return html`<p>Hello, ${this.name}!</p>`; } } customElements.define('simple-greeting', SimpleGreeting);
- Server Render the component
import { render } from '@lit-labs/ssr/lib/render-with-global-dom-shim.js'; import { html } from 'lit'; import './greeting.js'; import Koa from 'koa'; import koaNodeResolve from 'koa-node-resolve'; import { Readable } from 'stream'; const { nodeResolve } = koaNodeResolve; const app = new Koa(); const port = 8080; app.use(async (ctx) => { ctx.type = 'text/html'; ctx.body = Readable.from(render(html` <simple-greeting></simple-greeting> <simple-greeting name="SSR Works!"></simple-greeting> `)); }); app.use(nodeResolve({})); app.listen(port, () => { console.log(`Server listening on port ${port}`); });
Live Reproduction Link
https://stackblitz.com/github/thescientist13/lit-ssr-create-render-root
Expected Results
No Declarative Shadow DOM would be present, just like in the Lit Playground
<simple-greeting>
<style>p { color: blue }</style>
<!--lit-part EvGichL14uw=--><p>Hello, <!--lit-part-->Somebody<!--/lit-part-->!</p><!--/lit-part-->
</simple-greeting>Actual Results
Declarative Shadow DOM is still rendered
<simple-greeting>
<template shadowroot="open">
<style>p { color: blue }</style>
<!--lit-part EvGichL14uw=--><p>Hello, <!--lit-part-->Somebody<!--/lit-part-->!</p><!--/lit-part-->
</template>
</simple-greeting>Browsers Affected
- Chrome
- Firefox
- Edge
- Safari 11
- Safari 10
- IE 11
- NodeJS
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Contributions WelcomeIssues that we would accept a PR forIssues that we would accept a PR for
Type
Projects
Status
📋 Triaged

