Skip to content

[labs/ssr] Cannot SSR a dynamic tag with unsafeStatic #2246

@shakyShane

Description

@shakyShane

https://gist.github.com/shakyShane/423b19e9f479b06369eb90f4f503310a

The following stand-alone code examples both cause the error Error: unexpected final partIndex: 0 !== 1.

I'm using unsafeStatic in a controlled way (eg: not user-provided data).

import "@lit-labs/ssr/lib/render-with-global-dom-shim.js";
import { render as renderDomShim } from "@lit-labs/ssr/lib/render-with-global-dom-shim.js";
import { html, unsafeStatic } from 'lit/static-html.js'
import { LitElement } from 'lit'

/**
 * Rendering a static `<p>` fails
 *
 * ```
 * Error: unexpected final partIndex: 0 !== 1
 * ```
 */
const staticP = unsafeStatic('p');
for (const part of renderDomShim(html`<${staticP}>hello</${staticP}>`)) {
  console.log(part);
}

/**
 * Rendering a custom element also fails
 */
customElements.define('any-thing', class extends LitElement {
  render() {
    return html`<p>Hello world</p>`
  }
})

const element = unsafeStatic('any-thing');
for (const part of renderDomShim(html`<${element}>hello</${element}>`)) {
  console.log(part);
}

Any help will be greatly appreciated :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions