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

[labs/ssr] Non-array iterables fail to render #3122

Closed
augustjk opened this issue Jul 7, 2022 · 1 comment · Fixed by #3905
Closed

[labs/ssr] Non-array iterables fail to render #3122

augustjk opened this issue Jul 7, 2022 · 1 comment · Fixed by #3905
Assignees

Comments

@augustjk
Copy link
Member

augustjk commented Jul 7, 2022

Which package(s) are affected?

SSR (@lit-labs/ssr)

Description

When template contains iterables besides an array, for instance like a Set, SSR does not actually render the values.

For example:

This

  render() {
    return html`<p>new Set([1, 2, 3])</p>`;
  }

results in a paragraph tag containing [object Set].

The same is true for other iterables that normally work client-side like Map or Generator, which means using the map() directive results in [object Generator].

This also breaks during hydration as there's a mismatch of the number of parts, displaying the following error:

Error: unexpected longer than expected iterable

Reproduction

https://stackblitz.com/edit/koa-starter-3x2kbs?file=index.js

Workaround

Use Array.from()

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

2.2.1

Browser/OS/Node environment

Node version: v16.15.0

@nebarf
Copy link
Contributor

nebarf commented Jul 11, 2022

Looking at https://github.com/lit/lit/blob/main/packages/labs/ssr/src/lib/render-lit-html.ts#L594, I can confirm what @augustjk reported since the check is on Array instead of Iterable objects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants